我希望有人能够帮助我朝正确的方向发展?我正在尝试编写一个查询,其中的报告将显示订单总数和该订单号的已售产品数量,我粘贴了现有商品,并希望我走上了正确的道路。提前致谢!

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

最佳答案

显示订单总数和该订单号出售的产品数量


应该这样做:

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

关于mysql - 显示订单总数和订单编号的已售产品数量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42751653/

10-11 04:54