count & distinct

From: "Andrea Aime" <aaime(at)comune(dot)modena(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: count & distinct
Date: 2000-06-15 10:32:46
Message-ID: 3948B0CE.CEC21979@comune.modena.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)...

Well, maybe I should create a new aggregate
function, but before spending time on PGSQL
guide I would like to know if someone can
give me a fast tip... ;-)
Thanks in advance
Andrea

PS: well, of course I can open a cursor on
a "select distinct column from table" and then
loop over the cursor couting how many values
there are, but it seem a bit ugly...

Responses

Browse pgsql-general by date

  From Date Subject
Next Message lampe 2000-06-15 10:41:43 libpgtcl.so missing from pgaccess on FreeBSD4.0?
Previous Message Marcos Lloret 2000-06-15 10:04:58 DateStyle is Postgres with US (NonEuropean) conventions