Subquery having testcase

When you add a having clause to a nested groupBy query, it seems to alter the result order.