X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3A3F43A3F81 for ; Tue, 16 Nov 2004 20:03:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73801-01 for ; Tue, 16 Nov 2004 20:03:35 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 8A2EC3A3F60 for ; Tue, 16 Nov 2004 20:03:36 +0000 (GMT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 759BC354F6; Tue, 16 Nov 2004 12:03:35 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 63315351CF; Tue, 16 Nov 2004 12:03:35 -0800 (PST) Date: Tue, 16 Nov 2004 12:03:35 -0800 (PST) From: Stephan Szabo To: "Thomas F.O'Connell" Cc: PgSQL - SQL Subject: Re: Counting Distinct Records In-Reply-To: <1B2F7B00-3808-11D9-95C2-000D93AE0944@sitening.com> Message-ID: <20041116115807.E79990@megazone.bigpanda.com> References: <1B2F7B00-3808-11D9-95C2-000D93AE0944@sitening.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/156 X-Sequence-Number: 19475 On Tue, 16 Nov 2004, Thomas F.O'Connell wrote: > I am wondering whether the following two forms of SELECT statements are > logically equivalent: > > SELECT COUNT( DISTINCT table.column ) ... > > and > > SELECT DISTINCT COUNT( * ) ... Not in general. The former counts how many distinct table.column values there are. The distinct in the latter would be basically meaningless unless there's a group by involved.