Improved GROUP BY queries