Re: [SQL] DISTINCT & COUNT

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] DISTINCT & COUNT
Дата
Msg-id 16209.943640367@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [SQL] DISTINCT & COUNT  (Stuart Rison <rison@biochemistry.ucl.ac.uk>)
Список pgsql-sql
Stuart Rison <rison@biochemistry.ucl.ac.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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] 6.5.3 - backend closes if wrong parameters to NULLIF, CASE
Следующее
От: "Zodiac Speaker"
Дата:
Сообщение: TEST MESSAGE - PLEASE IGNORE