From: tjk@tksoft.com <tjk@tksoft.com>
To: drew@albatross.co.nz
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Counting the number of distinct rows returned
Date: Wed, 18 Aug 1999 22:20:36 -0700 (PDT)
Message-ID: <199908190520.WAA20898@uno.tksoft.com> (raw)
In-Reply-To: <4.1.19990819115506.00cfd890@pern.csarc.otago.ac.nz>
Drew,
Not really the answer you were asking, but in general, your
program will probably be using some interface other than
psql, i.e. libpq or Pg.pm, or whatever.
E.g. in C, if your PgQuery struct is pg1, then you
would do your query and retrieve the number of records
found with "pg1->PQntuples(pg1->reply)"
Troy
>
> 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
>
>
>
> ************
> 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: tjk@tksoft.com, drew@albatross.co.nz
Subject: Re: [SQL] Counting the number of distinct rows returned
In-Reply-To: <199908190520.WAA20898@uno.tksoft.com>
References: <4.1.19990819115506.00cfd890@pern.csarc.otago.ac.nz> <199908190520.WAA20898@uno.tksoft.com>
* 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