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 = 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.
It seems that subselects aliased in the SELECT clause of a GROUP BY query
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!
--
-Josh Berkus
Aglio Database Solutions
San Francisco