Aliased SubSelect in HAVING clause bug -- in progress? - Mailing list pgsql-bugs

From Josh Berkus
Subject Aliased SubSelect in HAVING clause bug -- in progress?
Date
Msg-id 200303112057.29399.josh@agliodbs.com
Whole thread Raw
Responses Re: Aliased SubSelect in HAVING clause bug -- in progress?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Folks,

I don't think I'm the first to report this, but:

SELECT a.id, b.type, max(b.number),
      (SELECT count(*) from c where c.b_type =3D b.type) as count_c
FROM a, b
WHERE a.id =3D b.a_id
GROUP BY a.id, b.type
HAVING count_c > 2;

Will get a:

ERROR: Attribute "count_c" not found.

It seems that subselects aliased in the SELECT clause of a GROUP BY query=
=20
cannot be referenced in the HAVING or ORDER BY clauses of any query.

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

Thanks!

--=20
-Josh Berkus
 Aglio Database Solutions
 San Francisco

pgsql-bugs by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: performance for MIN,MAX aggregates
Next
From: Tom Lane
Date:
Subject: Re: Aliased SubSelect in HAVING clause bug -- in progress?