How would I show, for example, the 10 most populous products in a table?
I have a sales table for example, that contains sales for 20 beers, 10 nachos, 5 peanuts, 2 hotdogs and 4 breakfasts.
Is there a way to automatically calculate and see which is the most popular, and show them in descending order?
edit:
My table is as follows
Tablename: sales
Fields:
- product (varchar)
- quantity (int)
- cost (decimal)
- saledate (date)
One sale record could count as more than one sale of a product, because of the quantity field.
I also have a guests table, which only has the fields name and country, and was wanting to show say, the top 5 most populous countries in the table.