Re: Aliased SubSelect in HAVING clause bug -- in progress?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: josh(at)agliodbs(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Aliased SubSelect in HAVING clause bug -- in progress?
Date: 2003-03-12 06:13:40
Message-ID: 24750.1047449620@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> SELECT a.id, b.type, max(b.number),
> (SELECT count(*) from c where c.b_type = b.type) as count_c
> FROM a, b
> WHERE a.id = b.a_id
> GROUP BY a.id, b.type
> HAVING count_c > 2;
> Will get a:
> ERROR: Attribute "count_c" not found.

As it should.

> I'd guess that this is being worked on for 7.4/8.0?

No, because it's not a bug. The SELECT list is evaluated after HAVING,
so what you are asking for is an impossibility in the SQL semantic
model.

(Yeah, I know there's some laxity in GROUP BY ... one of our worse
mistakes IMHO ...)

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message cn cn 2003-03-12 12:13:53 RI Bug In Inherited Table
Previous Message Josh Berkus 2003-03-12 04:57:29 Aliased SubSelect in HAVING clause bug -- in progress?