Re: [HACKERS] VIEWS, DISTINCT and COUNT

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: [HACKERS] VIEWS, DISTINCT and COUNT
Дата
Msg-id 199911040052.AAA18660@linda.lfix.co.uk
обсуждение исходный текст
Ответ на VIEWS, DISTINCT and COUNT  (Brian Hirt <bhirt@mobygames.com>)
Список pgsql-hackers
Brian Hirt wrote: >Okay, > >I'm used to a feature that allows combining count and distinct in Sybase.  >I thought it
wasstandard SQL and expected to see it in Postgres.  Whatever >the case might be, postgres does not seem to support
this. I keep running >into queries that I cannot write.  Here's the skinny: > >"select count(distinct id) from table"
isnot supported. 
 

I'm not convinced I understand what your query would do, but it sounds as
if you need to use GROUP BY.  For example:

lfix=> select custid, count(custid) from invoice group by custid;
custid  |count
--------+-----
ACECS   |    1
ADG     |    8
FALKIRK |    1
JEFSYS  |   25
SOLPORT |   15
(5 rows)

lfix=> select count(*) from invoice;
count
-----  50
(1 row)

Is that what you want to achieve?

--      Vote against SPAM: http://www.politik-digital.de/spam/                ========================================
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver              PGP key from public servers; key
ID32B8FAA1                ========================================    "Lo, children are an heritage of the LORD; and
the      fruit of the womb is his reward."        Psalms 127:3 
 




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

Предыдущее
От: Brian Hirt
Дата:
Сообщение: VIEWS, DISTINCT and COUNT
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] VIEWS, DISTINCT and COUNT