Skip to content
Advertisement

I have a table that contains a set of products purchased and their total quantities. How to get the product having minimum quantity for that month?

I want to extract the products corresponding to each month having minimum and the maximum quantity. That is for month 1 the product having the least quantity that is “Butter” should be displayed along with the quantity and the product having the maximum quantity that is “Eggs” should be displayed.

Advertisement

Answer

You can try to use MAX and MIN by month in subquery then self join

another way you can use exists subquery.

Query 1:

Results:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement