mysql query help with counting!
Hi,
I have a simple problem, but i don't know how to fix it or what it is called. I've searched on the internet and everything, but my approach is probably wrong since i have been using SELECT user, SUM...
Anyways, i need a query that can SELECT all the data from the database, and list it by outputting the top 10 users (each user per row) from the database. Clarifying from what i just said, here is how the table would look:
USER
Bob
Bob
Bob
Sarah
Sarah
George
So essentially, i want to select the user from the database that has the most occurrences.
What would the query be for me to select the user that has the most occurances and list it from that order descending?
The output should be:
1. Bob
2. Sarah
3. George
(kind of like a contest)
Each name is on a seperate row in the table. The user that has the most rows should be first place and so on.
Can anyone help please?
Thanks!
-George
|