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
if you want to print the names join users table,
select user_name, count(*) from users inner join messages m on users.userid=m.messageid group by userid order by count(*) desc;