From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Stuart Rison <rison(at)biochemistry(dot)ucl(dot)ac(dot)uk> |
Cc: | Moray McConnachie <moray(dot)mcconnachie(at)computing-services(dot)oxford(dot)ac(dot)uk>, pgsql-sql <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | Re: [SQL] DISTINCT & COUNT |
Date: | 1999-11-26 18:19:27 |
Message-ID: | 16209.943640367@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Stuart Rison <rison(at)biochemistry(dot)ucl(dot)ac(dot)uk> writes:
> You can however do:
> SELECT DISTINCT c.cid
> FROM a,b,c
> WHERE a.aid=b.aid
> AND a.somefield=1 and a.otherfield=2
> AND c.cid=a.cid;
> and if your are using a interface (e.g. DBI::DBD::Pg) then you can get
> the number of tuples returned...
Or do the SELECT into a temp table, followed by fetching count(*) on the
temp table. Ugly, but avoids transferring what might be a lot of rows
to the frontend.
DISTINCT within aggregate functions is on the TODO list, but I don't
know when it will happen.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Zodiac Speaker | 1999-11-26 19:56:49 | TEST MESSAGE - PLEASE IGNORE |
Previous Message | Tom Lane | 1999-11-26 18:06:00 | Re: [SQL] 6.5.3 - backend closes if wrong parameters to NULLIF, CASE |