Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: mysql query help with counting!
01-25-2013, 09:25 PM #1
- Join Date
- Dec 2011
- Thanked 0 Times in 0 Posts
mysql query help with counting!
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:
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:
(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?
01-25-2013, 09:47 PM #2
- Join Date
- Jul 2010
- Thanked 44 Times in 44 Posts
Here is one that I use.
SELECT count(ticket_number) as count, ticket_user FROM tickets group by ticket_user order by count DESC LIMIT 10
If you can't stand behind your troops, feel free to stand in front of themSemper Fidelis