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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.