Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Order by count of rows
12-24-2013, 12:46 PM #1
- Join Date
- Jul 2011
- Thanked 0 Times in 0 Posts
Order by count of rows
I have database table like that:
and the data goes like that:
I want to make SQL query that will order this results by the user with the most values
if userid 1 has 6 rows included his id, and it's the highest (no more users with more than 6 rows) it will show him first.
I am using PHP.
--Thanks in advanceNeed domain? Buy Cheap Domain at Rapid Host :)
12-24-2013, 07:49 PM #2Code:
SELECT userid, COUNT(value) AS howmany GROUP BY userid ORDER BY howmany DESC LIMIT 1Be yourself. No one else is as qualified.