I need to compose a SQL statement as follows:
I have a table with many items, each item having a category. In total there are 3 categories.
I need to select the DISTINCT categories and then order them by number of items within each category.
Would this be a good way? Or too slow?
SELECT DISTINCT category, count(*) AS counter
FROM item_descr
GROUP BY category
ORDER BY counter DESC
The
DISTINCTis not needed since you are usingGROUP BY category: