Adds back missing GROUP BY clause