I want to find out the products that have been ordered the least amount of times without using order by desc or top 1 etc. My query seems to get the min calculation right but the productID and name don't match
SELECT T.ProductID, ProductName, MIN(Total_Quantity)
FROM (SELECT ProductID, SUM(Quantity) as Total_Quantity
FROM orderdetails
GROUP BY orderdetails.ProductID) as T
JOIN products p on T.ProductID = p.ProductID
my code is pasted above and this is the output:
Here is the sum of quantity per product ordered