user19629867
user19629867

Reputation:

How to get the MAX Value In Quantity_by_Category?

SELECT p.ProductID, p.ProductCategory, SUM(pd.Quantity) AS Quantity_by_Category 
FROM Purchase_Details pd 
INNER JOIN Products p
ON pd.ProductID = p.ProductID
GROUP BY pd.ProductID
ORDER BY p.ProductID;

enter image description here

Upvotes: 1

Views: 44

Answers (2)

Hendra Sirait
Hendra Sirait

Reputation: 57

you can put order by to Quantity_by_Category desc

Upvotes: 0

Dmitry Polovinkin
Dmitry Polovinkin

Reputation: 189

Can be done with aggregate function MAX() using your query as a subquery:

SELECT MAX(Quantity_by_Category)
FROM (your_query) t1

Upvotes: 2

Related Questions