Home Forums Programming General Need help on query when sum of total show inaccurate result RE: Need help on query when sum of total show inaccurate result

  • Process: - When user buy item and check out then there's cart and cart items table to store the transaction.
                  - 1 cart_id have many item which stored in cart items table.
                  - After purchase succeed, then will generate a purchase order id and stored in purchase order table .
                  - In purchase order table, id_cart and status will be stored.

    From  here, i am trying to calculate quantity based on id_product or id branch or etc from the purchase made.
    There is receiving and ordered quantity field, which in some cases quantity received field might be null, so i will take ordered quantity value.

    cart item table

    cart table

    purchase order table