Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id JAA26781 for ; Thu, 19 Aug 1999 09:19:40 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id JAA07813; Thu, 19 Aug 1999 09:18:33 -0400 (EDT) To: Drew Whittle cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Counting the number of distinct rows returned In-reply-to: Your message of Thu, 19 Aug 1999 11:59:21 +1200 <4.1.19990819115506.00cfd890@pern.csarc.otago.ac.nz> Date: Thu, 19 Aug 1999 09:18:33 -0400 Message-ID: <7811.935068713@sss.pgh.pa.us> From: Tom Lane Drew Whittle 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