From: Sejin Oh <soh@cyberix.com>
To: Drew Whittle <drew@albatross.co.nz>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Counting the number of distinct rows returned
Date: Thu, 19 Aug 1999 09:56:50 -0400
Message-ID: <002501beea4a$b078d160$0301a8c0@turbo> (raw)
yeah... GROUP BY should do..
try this:
SELECT COUNT(*) FROM sales_by_region GROUP BY user_id;
Regards,
-----Original Message-----
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Drew Whittle <drew@albatross.co.nz>
Cc: pgsql-sql@postgreSQL.org <pgsql-sql@postgreSQL.org>
Date: Thursday, August 19, 1999 9:35 AM
Subject: Re: [SQL] Counting the number of distinct rows returned
>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
>
>************
>Check out "PostgreSQL Wearables" @ http://www.pgsql.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: soh@cyberix.com, drew@albatross.co.nz
Subject: Re: [SQL] Counting the number of distinct rows returned
In-Reply-To: <002501beea4a$b078d160$0301a8c0@turbo>
References: <002501beea4a$b078d160$0301a8c0@turbo>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox