andrewbadera
Programmer
the following statement:
SELECT DISTINCT(tOrder.intOrderID), SUM(CAST(ProductOrder.monTotal AS money)) As OrderTotal, ProductOrder.intProductID, tOrder.dtReceived, tOrder.dtShipped, Product.intProductID, tUser.intUserID FROM tblProductOrder As ProductOrder JOIN tblProduct AS Product ON Product.intProductID = ProductOrder.intProductID JOIN tblOrder AS tOrder ON tOrder.intOrderID = ProductOrder.intOrderID JOIN tblUser AS tUser ON tOrder.intUserID = tUser.intUserID WHERE tOrder.isActive = 1 GROUP BY tOrder.intOrderID, tOrder.dtReceived, tUser.intUserID, ProductOrder.intProductID, tOrder.dtShipped, Product.intProductID ORDER BY tOrder.intOrderID ASC, tOrder.dtShipped ASC
is returning to me a record for each item (ProductOrder.intProductOrderID) in each order rather than the list of individual orders (tOrder.intOrderID) with order totals (consisting of the SUM of OrderProduct.monTotal for all OrderProducts by intOrderID), as I had intended.
can anyone help me clean this up?
SELECT DISTINCT(tOrder.intOrderID), SUM(CAST(ProductOrder.monTotal AS money)) As OrderTotal, ProductOrder.intProductID, tOrder.dtReceived, tOrder.dtShipped, Product.intProductID, tUser.intUserID FROM tblProductOrder As ProductOrder JOIN tblProduct AS Product ON Product.intProductID = ProductOrder.intProductID JOIN tblOrder AS tOrder ON tOrder.intOrderID = ProductOrder.intOrderID JOIN tblUser AS tUser ON tOrder.intUserID = tUser.intUserID WHERE tOrder.isActive = 1 GROUP BY tOrder.intOrderID, tOrder.dtReceived, tUser.intUserID, ProductOrder.intProductID, tOrder.dtShipped, Product.intProductID ORDER BY tOrder.intOrderID ASC, tOrder.dtShipped ASC
is returning to me a record for each item (ProductOrder.intProductOrderID) in each order rather than the list of individual orders (tOrder.intOrderID) with order totals (consisting of the SUM of OrderProduct.monTotal for all OrderProducts by intOrderID), as I had intended.
can anyone help me clean this up?