Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

When is GROUP BY actually required?

Brian TkatchFeb 14 2014 — edited Feb 19 2014

I was wondering about the GROUP BY statement, and being Friday, i thought i would ask it here.

SELECT Moo, SUM(Cow) FROM Moo; will fail because there is a COLUMN and aggregate with no corresponding GROUP BY. However, the GROUP BY can be inferred...even SQL Developer will (when the option is checked) write the obvious GROUP BY clause for you! The GROUP BY clause seems as redundant as the "SELECT * FROM" of an EXISTS clause.

Imagine i had my way: the GROUP BY clause would be optional, that is, an inferred GROUP BY clause would be acceptable. In such a case when would a GROUP BY clause be required? Put another way, when can an explicit GROUP BY clause produce different results than an inferred one?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2014
Added on Feb 14 2014
6 comments
3,456 views