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

  • testingpoke1 - Tuesday, November 28, 2017 8:31 AM

    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.

    So why do you think id_product 3 should be in your results? You have no row in the purchase table for id_cart 2.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/