Select pl.ProductName AS 'Product Name',
Sum(OrderQty),
(od.OrderQty * pl.Price) as 'Total Amount'
From ProductList pl
Inner Join OrderDetails od ON pl.ProductID = od.ProductId
Group By pl.ProductName
但显示此错误消息:
消息8120,级别16,状态1,行2列“OrderDetails.OrderQty”在选择列表中无效,因为它不包含在聚合函数或GROUP BY子句中。
消息8120,级别16,状态1,行2列“ProductList.Price”在选择列表中无效,因为它不包含在聚合函数或GROUP BY子句中。“
答案 0 :(得分:0)
你没有总结总数:
Select pl.ProductName AS 'Product Name',
SUM(OrderQty),
SUM(od.OrderQty * pl.Price) as 'Total Amount'
From ProductList pl
Inner Join OrderDetails od ON pl.ProductID = od.ProductId
Group By pl.ProductName