Fixed missing GROUP BY