Comment Comment by tgv I don't think HAVING is strictly needed, but you need to use a sub-query. SELECT x ... HAVING y => SELECT * FROM (x ...) t WHERE y parent tgv 4 years ago