tensojka
tensojka

Reputation: 310

Count unique values in a column

I have this table:

value1-------value2------time
1            2           1440273663
1            1           1440273699
2            3           1448293763
1            1           1440273663
3            2           1440273693

And I want to count the number of unique values in column 1. For this example table, this would be 3.

Upvotes: 0

Views: 293

Answers (2)

DhruvJoshi
DhruvJoshi

Reputation: 17126

You can use a query like below for a table named t with column value1

select count(distinct value1) from t;

Here's a demo sql fiddle:http://sqlfiddle.com/#!9/2b903/1

Upvotes: 1

Taher  Rahgooy
Taher Rahgooy

Reputation: 6696

Use distinct:

Select count(distinct value1) from table

Upvotes: 2

Related Questions