Możesz mieć wewnętrzny wybór, taki jak:
SELECT count_of_foo, count(bar), baz
FROM (SELECT count(foo) as count_of_foo, bar, baz, other1, other2 FROM complex_query WHERE foo = bar HAVING count(foo) > 1) inner_query
GROUP BY count_of_foo, baz.
To da ci możliwość dodania większej liczby grup po klauzuli HAVING.