Fix SQL group syntax