簡體   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