Hi,

I am just starting to play around with Postgres SQL and have stumbled apon a problem.

I have a table that has quantity's from 'orders'. I can run the following query;

SQL
SELECT prodID, description, SUM(quantity) FROM orderItem NATURAL JOIN product GROUP BY prodID, description ORDER BY SUM(quantity) DESC LIMIT 1 ;


which gives the the 'top selling' product and displays only the top selling product. What I would like to work out is if there is two 'top selling' products, how can i display only the two products (or more products if they are all equal first)

Thanks

 

 

 


Comment/Reply (w/o sign-up)