Received: from as.tksoft.com (gyw.com [206.117.28.161] (may be forged)) by hub.org (8.9.3/8.9.3) with ESMTP id BAA11984 for ; Thu, 19 Aug 1999 01:29:25 -0400 (EDT) (envelope-from tjk@tksoft.com) Received: (from tjk@tksoft.com) by uno.tksoft.com (8.8.8/8.8.8) id WAA20898; Wed, 18 Aug 1999 22:20:37 -0700 From: "tjk@tksoft.com" Message-Id: <199908190520.WAA20898@uno.tksoft.com> Subject: Re: [SQL] Counting the number of distinct rows returned To: drew@albatross.co.nz (Drew Whittle) Date: Wed, 18 Aug 1999 22:20:36 -0700 (PDT) Cc: pgsql-sql@postgreSQL.org In-Reply-To: <4.1.19990819115506.00cfd890@pern.csarc.otago.ac.nz> from "Drew Whittle" at Aug 19, 99 11:59:21 am Content-Type: text 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 > >