我希望有人可以帮助指导我朝着正确的方向前进?我正在尝试编写一个查询,其中报告将显示订单总数和为该订单号销售的产品数量,我粘贴了我所拥有的并希望我走在正确的道路上。提前致谢!
select distinct od.OrderID, AVG( od.unitprice * od.quantity / od.Discount) 'try',
od.ProductID
from OrderDetails od
where od.OrderID = 10251
group by od.orderid
答案 0 :(得分:0)
显示订单总数和该订单号销售的产品数量
这应该这样做:
SELECY OrderID, -- Order Id
count(*) as items, -- number of products
SUM(unitprice * quantity / Discount) as total -- order total
FROM OrderDetails
WHERE OrderID = 10251
GROUP BY OrderID