When we write 'group by' in any relational database the syntax always requires the values. Can't we make the syntax a little simple by not mandatory to provide group by values? Any columns mentioned in the select is going to be grouped by default.

There are a few things to consider though

  • aggregate columns in select are not included
  • if you want to group by certain columns but don't want to select them, then you can provide values in group by clause

Asking this question to understand if there are any reasons of why group by cluase is always requiring value or maybe I'm missing some other reason about SQL syntax semantics.


1 Answer 1


The group by construct has been around for many, many years, so I guess there just hasn't been any demand for this kind of "syntactic candy" (although I did write an M.I. Application some time ago that did exactly this, just in Application code!).

I'd say it's a similar risk to using "select *".

If such a construct did exist, you cvould get into the situation where somebody [else] might add some more fields into the select list without realising that they needed to go into the [much shorter and very easy to miss] group by clause as well. If those new fields happened to be Blob fields containing gigabytes of Video data, or really, really big Character data, then the query would probably start to perform ... "rather poorly".

Where SQL is concerned, being explicit is almost always the best policy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.