简体   繁体   English

列出列的所有不同值及其计数

[英]List all distinct values of column and their count

I have a column with different text values. 我有一列具有不同的文本值。 How can I get a list of all the unique values and the count of the appearance of them in the column? 如何获得所有唯一值的列表以及该列中它们的外观计数?

Simplest way is to use GROUP BY 最简单的方法是使用GROUP BY

select text_column, count(*) from text_table group by text_column

more info - http://www.w3schools.com/sql/sql_groupby.asp 更多信息-http: //www.w3schools.com/sql/sql_groupby.asp

SELECT column_name
     , COUNT(*)
  FROM table_name
  GROUP BY column_name
;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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