-2

I have a table with videos and every table have a username.

Example:

username | title |

John         | My car is the best

John         | My car

John         | My car

Maria        | I like google

Maria        | I like google

Jerry        | I like cheese

How to select username with most data and ordering desc?

Example:

John  -> 3
Maria -> 2
Jerry -> 1
Maheswaran Ravisankar
  • 17,652
  • 6
  • 47
  • 69
user3233336
  • 27
  • 1
  • 6

3 Answers3

1
select username,count(*) coun
from theTable
group by username 
order by coun desc
Dima
  • 8,586
  • 4
  • 28
  • 57
  • 1
    using count as a field name can get problematic since it's a reserved word. I'd suggest using something else as some compilers will balk that this. – xQbert Jan 24 '14 at 19:58
0

Try this sql query:

select username, times from
(select username, count(title) as times 
  from yourtable
group by username) qry
order by qry.times desc;
Hackerman
  • 12,139
  • 2
  • 34
  • 45
0

SELECT name, COUNT(1) AS c FROM table GROUP BY name ORDER BY c DESC

marcosh
  • 8,780
  • 5
  • 44
  • 74