A fun SQL project for beginners!
If you want to rank your results in order by frequency of occurrence, you can use COUNT() in any major RDBMS to get your results.
Try using a query like below :
SELECT name, COUNT(id) FROM table
WHERE type=’User’ AND id<>3 AND id IN (116,18,28) GROUP BY (id) ORDER BY COUNT(id) DESC;
Note that all you have to do is add GROUP BY to the counted column, and order by that count! I like to set DESC to make sure they’re descending (largest items on top) and adding LIMIT 20 in MySQL will only show you the top 20.
Cool stuff for noobs!



