Re: [SQL] Counting the number of distinct rows returned - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] Counting the number of distinct rows returned
Date
Msg-id 7811.935068713@sss.pgh.pa.us
Whole thread Raw
In response to Counting the number of distinct rows returned  (Drew Whittle <drew@albatross.co.nz>)
List pgsql-sql
Drew Whittle <drew@albatross.co.nz> writes:
> How can I return the number of records (ie a count(user_id)) when using a
> statement like this:

> select distinct user_id from sales_by_region;

count() with a GROUP BY will do what you want, I think --- see other
thread with Doug Younger for an example.

> I have tried things like:
> select count(distinct user_id) from sales_by_region (parse error)

Unfortunately we don't handle count(distinct ...) --- we should, since
it's in SQL92.
        regards, tom lane


pgsql-sql by date:

Previous
From: Dirk Lutzebaeck
Date:
Subject: does LIMIT save time?
Next
From: "Sejin Oh"
Date:
Subject: Re: [SQL] Counting the number of distinct rows returned