Remove group by/order by columns if EXISTS subquery doesn't have HAVING expression