counting mysql values

╄→尐↘猪︶ㄣ 提交于 2019-12-31 06:20:40

问题


I have a table with two fields, TAG_ID and TAG_DESC

my primary is tag_id.

I'm looking for a query that will display each TAG_DESC and the amount of times it occurs next to it.

Thanks,


回答1:


  SELECT TAG_DESC as 'Description', 
         COUNT(TAG_DESC) as 'Occurances' 
    FROM table_name 
GROUP BY TAG_DESC



回答2:


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


来源:https://stackoverflow.com/questions/3808062/counting-mysql-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!