Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by mail.postgresql.org (8.11.3/8.11.1) with ESMTP id f2K4kiN40694 for ; Mon, 19 Mar 2001 23:46:44 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 27008; Mon, 19 Mar 2001 20:46:39 -0800 From: "Josh Berkus" Subject: Re: count() and multiple tables To: Stephan Szabo , Joseph Shraibman Cc: "pgsql-sql@postgresql.org" X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Mon, 19 Mar 2001 20:46:39 -0800 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200103/384 X-Sequence-Number: 2052 Stephan, Joseph, > Because d.id was guaranteed to be unique, you might be able to > count(distinct d.id) and get the result you want. [I think the > subquery is a nicer way of representing it] Plus a several SQL implementations don't implement the DISTINCT until after the COUNT, reuslting in a still-inflated (and sometimes varying!) COUNT. It won't work properly in T-SQL or MS Office SQL, for example. -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco