fix GROUP BY clause