简体   繁体   English

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

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

I'm hoping someone might be able to help guide me in the right direction? 我希望有人可以帮助我朝正确的方向发展吗? I'm trying to write a query where the report will display the order total and number of products sold for that order number, I pasted what I have and hopefully I am headed on the right path. 我正在尝试编写一个查询,其中报告将显示该订单号的订单总数和已售产品数量,我粘贴了现有商品,并希望我走上了正确的道路。 Thanks in advance! 提前致谢!

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

display the order total and number of products sold for that order number 显示订单总数和该订单号出售的产品数量

This should do it: 应该这样做:

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