1

I am trying to get the number of comments left by each commenter (subscriber) and order from highest to least.

For Starters this was the first link I went to :

SQL: How to get the count of each distinct value in a column?

Similar problem, except in my first column the values may repeat. Mine looks something like this.

email   | comment
--------------------
foo@bar | blah..
bar@bar | blah..
zob@bar | blah..
foo@bar | blah..
foo@bar | blah..
bar@bar | blah..

and essentially all I need to do is get an output like this

-foo@bar (3)
-bar@bar (2)
-zob@bar (1)

I know this may be very trivial, I just don't use SQL queries that often.

Community
  • 1
  • 1

1 Answers1

4
select 
  email, count(*)
from
  mytable
group by email
order by count(*) desc

Here's a fiddle

crthompson
  • 15,653
  • 6
  • 58
  • 80