Re: [HACKERS] VIEWS, DISTINCT and COUNT

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: bhirt(at)mobygames(dot)com
Cc: pgsql-hackers(at)postgreSQL(dot)org, olly(at)linda(dot)lfix(dot)co(dot)uk
Subject: Re: [HACKERS] VIEWS, DISTINCT and COUNT
Date: 1999-11-04 00:52:44
Message-ID: 199911040052.AAA18660@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Brian Hirt wrote:
>Okay,
>
>I'm used to a feature that allows combining count and distinct in Sybase.
>I thought it was standard 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" is not 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(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP key from public servers; key ID 32B8FAA1
========================================
"Lo, children are an heritage of the LORD; and the
fruit of the womb is his reward." Psalms 127:3

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-11-04 00:58:46 Re: [HACKERS] VIEWS, DISTINCT and COUNT
Previous Message Brian Hirt 1999-11-04 00:13:31 VIEWS, DISTINCT and COUNT