Re: Why is "group by" obligatory in SQL?
Date: Fri, 24 Jul 2009 03:22:11 -0500
Hans Mayr wrote:
> I still don't know if there is a better group to post general
> questions about SQL and the background. So I hope nobody minds ;-)
> My question is: Why do you have to state the GROUP BY explicitly in
> SQL? Why isn't it enough to write "select a_field, sum(b_field) from
> c_table;"? What additional value is generated by "group by a_field"?
Who can know how the original designers arrived at their decision? There were certainly other languages from the early SQL era (such as QUEL) that would allow a similar formulation to what you propose, meaning what you intend. (And indeed QUEL would allow other sensible things with aggregates that SQL still doesn't easily allow.)
Personally I imagine the logic of SQL aggregation got defined in haste, was "good enough", and they just moved swiftly on to the next challenge. A small team, internal IBM rivalries, publication demands, etc. finished the job.
-- RoyReceived on Fri Jul 24 2009 - 10:22:11 CEST