Re: invalid 'having' clause

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Iain" <iain(at)mst(dot)co(dot)jp>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: invalid 'having' clause
Date: 2004-12-02 02:54:39
Message-ID: 1697.1101956079@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Iain" <iain(at)mst(dot)co(dot)jp> writes:
> Just a quick question out of curiosity, I was just wondering if this is
> supposed to be valid sql:

> select count(*) as cnt
> from sometable
> group by somecolumn
> having cnt > 1

No. The HAVING clause logically executes before the SELECT output list
does, so it makes no sense for it to refer to the output list entries.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message sad 2004-12-02 05:11:49 Re: SET AUTOCOMMIT TO OFF
Previous Message Michael Fuhr 2004-12-02 02:45:56 Re: grouping a many to many relation set