support subquery in HAVING clause