Received: from server1.cyberix.com (mail@server1.cyberix.com [207.106.53.10]) by hub.org (8.9.3/8.9.3) with ESMTP id JAA33652 for ; Thu, 19 Aug 1999 09:58:14 -0400 (EDT) (envelope-from soh@cyberix.com) Received: from turbo (max2-ppp-33.cyberix.com [207.8.199.97]) by server1.cyberix.com (8.8.5/8.8.5) with SMTP id JAA08317; Thu, 19 Aug 1999 09:51:36 -0400 (EDT) Message-ID: <002501beea4a$b078d160$0301a8c0@turbo> From: "Sejin Oh" To: "Drew Whittle" Cc: Subject: Re: [SQL] Counting the number of distinct rows returned Date: Thu, 19 Aug 1999 09:56:50 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 yeah... GROUP BY should do.. try this: SELECT COUNT(*) FROM sales_by_region GROUP BY user_id; Regards, -----Original Message----- From: Tom Lane To: Drew Whittle Cc: pgsql-sql@postgreSQL.org Date: Thursday, August 19, 1999 9:35 AM Subject: Re: [SQL] Counting the number of distinct rows returned >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 > >************ >Check out "PostgreSQL Wearables" @ http://www.pgsql.com