Skip to Main Content

Database Software

GROUP BY 1,2;

BPeaslandDBAMar 2 2015 — edited May 7 2020

I can write a SQL like the following:

SELECT col1,col2,col3 FROM my_table ORDER BY 1,2;

We all know "1,2" is shorthand for the first and second columns in my SELECT clause.

My idea is to do something similar for the GROUP BY clause...

SELECT col1, col2, SUM(col3) FROM my_table GROUP BY 1,2;

Just an idea!
Brian

Comments
Post Details
Added on Mar 2 2015
27 comments
14,126 views