Josh Berkus <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to