So HAVING condition is evaluated for EACH ROW instead of just on the group? I think then the current approach is wrong in the engine.
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt "2) The <search condition> is applied to each group of T."