简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM