RE: count & distinct - Mailing list pgsql-general

From Andrew Snow
Subject RE: count & distinct
Date
Msg-id NHEALMDKDACEIPBNOOOCAEKACFAA.als@fl.net.au
Whole thread Raw
In response to count & distinct  ("Andrea Aime" <aaime@comune.modena.it>)
List pgsql-general
> Hi people. I would like to make a query that
> tells me how many distinct values there are
> in a column. Standard count doesn't seems
> to support a count distinct option.
> select distint count(*) of course doens't
> work (distinti clause is applied after the
> result are calculated). I've tried to define
> a view, but it didn't worked (
> create view distValues as select distinct ...
> but views doesn't support distinct clause)...


SELECT COUNT(DISTINCT field_name) FROM table_name;

Works for me in v7.


Regards,
Andrew Snow
als@fl.net.au



pgsql-general by date:

Previous
From: "Andrea Aime"
Date:
Subject: count & distinct
Next
From: Vashenko Maxim
Date:
Subject: Re: group by problem