Re: Counting Distinct Records

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: "Thomas F(dot)O'Connell" <tfo(at)sitening(dot)com>
Cc: PgSQL - SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Counting Distinct Records
Date: 2004-11-16 20:03:35
Message-ID: 20041116115807.E79990@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas F.O'Connell 2004-11-16 20:09:33 Re: Counting Distinct Records
Previous Message Thomas F.O'Connell 2004-11-16 19:45:45 Counting Distinct Records