Re: select syntax question - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: select syntax question
Date
Msg-id 20021101215900.GA2290@wolff.to
Whole thread Raw
In response to select syntax question  (Wei Weng <wweng@kencast.com>)
List pgsql-sql
On Fri, Nov 01, 2002 at 16:33:32 -0500, Wei Weng <wweng@kencast.com> wrote:
> This is what is on postgresql's manual page:
> 
> According to this syntax, SELECT DISTINCT COUNT(ID) FROM test
> should be valid while SELECT COUNT(DISTINCT ID) FROM test otherwise.
> 
> while in fact, both are valid.
> 
> Is there any difference between this two queries?

They mean different things.

The first will return the number of rows with non-null values for id.
Since only one row is returned it is guarenteed to be distinct so the
distinct keyword will have no effect.

The second form will return the number of distinct, non-null values for id
in the table.


pgsql-sql by date:

Previous
From: Wei Weng
Date:
Subject: select syntax question
Next
From: "Chad Thompson"
Date:
Subject: Re: making queries more effecient