繁体   English   中英

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

[英]Display the order total and the number of products sold for order number

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM