ustroetz
ustroetz

Reputation: 6292

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?

Upvotes: 0

Views: 108

Answers (2)

peter
peter

Reputation: 15079

Simplest way is to use GROUP BY

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

more info - http://www.w3schools.com/sql/sql_groupby.asp

Upvotes: 3

caleb.breckon
caleb.breckon

Reputation: 1364

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

Upvotes: 1

Related Questions