SELECT OrderID, count(ProductID), (unitPrice * Quantity) as 'Product Total Amount', Discount, (unitPrice * Quantity * (1-Discount)) as 'Product Total Amount with a discount' from [Order Details]
Asked
Active
Viewed 63 times
-2
-
1Please post the complete error message - and I believe it tells you exactly what is wrong – Dale K Aug 27 '22 at 23:29
-
2And please ask a question in the question, not just the title – Dale K Aug 27 '22 at 23:30
-
3The message will literally spell out what the problem is: `Column 'ProductID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.` See [Aleksandar Vasilevski's answer](https://stackoverflow.com/a/73515045/215042) or the many duplicate questions. Next time, use the search first. – RobIII Aug 27 '22 at 23:30
-
1study aggregate functions – Amit Verma Aug 28 '22 at 02:52
1 Answers
0
Any column in your select statement that is not in the aggregate function must be in the GROUP BY clause.

Aleksandar Vasilevski
- 132
- 2
- 9