An order can consist of several rows and so the OrderId is not unique. How can I do a SUM and not have to GROUP BY in order for the SQL to parse correctly?
SELECT DISTINCT OrderId, SUM(ProductPrice * ProductQuantity ) as Total
FROM OrderDetails
GROUP BY OrderId
If I take off the GROUP BY line then I get
'OrderDetails.OrderId' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
EDIT
My desired outcome is if an order consisted of 2 products then it should output both rows.
The group by is outputting 1 row.