Suppose, I want to show a list of users ordering by the most number of messages they have sent.
I have 2 tables: Users and Messages
Users
Messages
I h
SELECT user, COUNT(*) FROM messages GROUP BY user ORDER BY count(*) DESC;