pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Wei Weng <wweng@kencast.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: select syntax question
Date: Fri, 1 Nov 2002 15:59:00 -0600
Message-ID: <20021101215900.GA2290@wolff.to> (raw)
In-Reply-To: <1036186412.25294.2.camel@Monet>
References: <1036186412.25294.2.camel@Monet>

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.



view thread (3+ messages)  latest in thread

Message-ID: <20021101215900.GA2290@wolff.to>
Permalink:  ../20021101215900.GA2290@wolff.to/
Also on:    postgresql.org/message-id/20021101215900.GA2290@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, wweng@kencast.com
  Subject: Re: select syntax question
  In-Reply-To: <20021101215900.GA2290@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox