Counting the number of distinct rows returned - Mailing list pgsql-sql

From Drew Whittle
Subject Counting the number of distinct rows returned
Date
Msg-id 4.1.19990819115506.00cfd890@pern.csarc.otago.ac.nz
Whole thread Raw
In response to Re: [SQL] index on more-than-one columns?  (Oleg Bartunov <oleg@sai.msu.su>)
Responses Re: [SQL] Counting the number of distinct rows returned  ("tjk@tksoft.com" <tjk@tksoft.com>)
Re: [SQL] Counting the number of distinct rows returned  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
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;

I have tried things like:

select count(distinct user_id) from sales_by_region (parse error)
select distinct count(user_id) from sales_by_region (useless because count
is performed before the distinct)

HELP!

Thanks,

Drew




pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [SQL] Using intersect in subquery
Next
From: Doug Younger
Date:
Subject: Problems using count() with a join