Re: Why is "group by" obligatory in SQL?
Date: Thu, 23 Jul 2009 10:20:49 -0300
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"?
> Thanks and best,
Because SQL made the mistake of allowing duplicate rows and not requiring candidate keys, in SQL, one could group by addtional columns:
select a_field, sum(b_field)
group by a_field, d_field; Received on Thu Jul 23 2009 - 15:20:49 CEST