Re: Why using "Group By"

From: Bob Badour <bbadour_at_golden.net>
Date: Thu, 13 Mar 2003 14:37:50 -0500
Message-ID: <_z5ca.62$oP2.8381552_at_mantis.golden.net>


"Mikito Harakiri" <mikharakiri_at_ywho.com> wrote in message news:Id4ca.9$wV5.27_at_news.oracle.com...
> "oferbu" <junkbu_at_hotmail.com> wrote in message
> news:b9b409f2.0303130207.42f8ab91_at_posting.google.com...
> > Why do I need to add the "Group By" in
> > the following SQL:
> >
> > SELECT
> > CUSTOMER_CITY, COUNT(*)
> > FROM
> > CUSTOMER_TABLE
> >
> > Isn't it clear that I want to get the number of rows per city, so why
> > is it necessary to add:
> >
> > GROUP BY
> > CUSTOMER_CITY
> >
> > I mean to say that those added lines didn't give more information, and
> > any resonable person (or a good sql parser...) could have understand
> > what I really want at the first sql.
>
> select max(sum(sal)) from emp
>
> is not the same as
>
> select max(sum(sal)) from emp
> group by dept

Why discard logical identity? If you want to know the salary by department, ask for it:

select dept, max(sum(sal)) from emp

Does the max do anything though? Received on Thu Mar 13 2003 - 20:37:50 CET

Original text of this message