Skip to content
Advertisement

What does SQL clause “GROUP BY 1” mean?

Someone sent me a SQL query where the GROUP BY clause consisted of the statement: GROUP BY 1.

This must be a typo right? No column is given the alias 1. What could this mean? Am I right to assume that this must be a typo?

Advertisement

Answer

It means to group by the first column regardless of what it’s called. You can do the same with ORDER BY.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement