jake
jake

Reputation: 123

SELECT DISTINCT and count

the table looks like this:

tag | entryID
----+---------
foo | 1
foo | 2
bar | 3

And now i want to get all tags with its usage:

foo | 2
bar | 1

How can I do this?

Thank you

Upvotes: 12

Views: 16183

Answers (1)

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171411

select tag, count(*)
from MyTable
group by tag

Upvotes: 28

Related Questions