Maybe a similar syntax, "GROUP BY AUTO", could be useful, but I suspect it would quickly become a code smell - some people would slap "AUTO" in when they get an error in much the same way they slap "DISTINCT" in to fix an accidental cartesian product without actually thinking about the problem.
As irritating as having to list many columns in the GROUP cause of a statement with a wide output, I like that it has to be explicit: if I have the column lists wrong I've made an error and I don't want SQL Server to guess how to fix that error. Perhaps instead of missing a column in the grouping list I've instead messed up in the projection clause. And if the statement is getting inconvenient enough that the grouping clause is a significant irritation, perhaps it needs to be refactored more generally.
One further thing to note is that some DBs do automagically decide what to do when columns are neither in an aggregate or the grouping list: mySQL for instance will just return an arbitrary value from those that exist in the current group for such columns (IIRC the first value hit as the data is read). This leads to situations where the query seems to work fine until something changes in either the data balance or the available indexes (or some change is made to the query itself) that makes the processing happen a different way around so a different arbitrary value starts to get selected for the same group in the same query.
That's a great point
And as the name suggests its somewhat magic/implicit in its behavior.
No ANSI SQL result is altered by changing the order of GROUP BY.
I have literally never, ever wanted this. Why in the world would you group by any field not appearing in an aggregate?
Also, the group by can specify cubes and rollups, more over you may not want to group by any field, but rather an expression.
SELECT count(*), favorite_color, favorite_song
FROM person
GROUP BY ...
The "..." is of course favorite_color, favorite_song.Whether you want this or not, ANSI SQL requires that you group by at least these.
You could group by more more fields, such as favorite_pet, though that would be somewhat odd since you are did not include it in the result set.
That's true.
I still prefer DRY, but I can appreciate the WET perspective.
* Except for the special case when it's non-aggregated and I want duplicate rows in the result set. SQL allowing duplicate rows is a departure from the underlying relational paradigm.
For example, in the case of SQL, the GROUP BY clause is nearly always noise.
So much so that SQL database will tell you exactly what things you need to add to the GROUP BY to make it valid SQL. Those things are extraneous information that the database could (and already did) know.
(IMO, in an aggregated query, SQL ought to implicitly add all non-aggregated fields to the GROUP BY, the user may explicitly add fields to the GROUP BY if desired.)