"group by 1,2" is for lazy people who never have to support an application in production. It tells the database to group by the columns in the order that they come back in the result and is supported by most engines.
https://gist.github.com/AdamG/1128b86fdafca1e53a4bd5253a6882...