From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Wei Weng <wweng(at)kencast(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: select syntax question |
Date: | 2002-11-01 21:59:00 |
Message-ID: | 20021101215900.GA2290@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, Nov 01, 2002 at 16:33:32 -0500,
Wei Weng <wweng(at)kencast(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2002-11-01 22:00:09 | Re: Does this matter? |
Previous Message | Wei Weng | 2002-11-01 21:33:32 | select syntax question |