Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: GROUP BY Expression

Re: GROUP BY Expression

From: Newsworthy <hannum_at_ohio.edu>
Date: Fri, 23 Apr 1999 19:27:52 GMT
Message-ID: <FAnpvE.BHF@boss.cs.ohiou.edu>


Thanks -

--
Dave Hannum
Web Analyst/Programmer
Ohio University
hannum_at_ohio.edu
Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl> wrote in message news:7fq0la$2gc$1_at_weber.a2000.nl...
> Newsworthy wrote
> > SELECT *
> > FROM Students U, Sessions E, Seminars S
> > WHERE S.ID = E.ID AND
> > E.SID = U.SID AND
> > E.IID = 235
> > GROUP BY U.oak_id
> > ORDER BY U.NameLast, U.NameFirst
>
> In the group by part you should mention ALL columns you select, except for
> group by expressions like min(..), max(..), count(..) etc. For example:
>
> select age, sex, count(*)
> from students
> group by age, sex;
>
> would get you something like
>
> 18 F 15
> 18 M 20
> 19 F 22
> 19 M 26
> 20 F 4
> 20 M 8
>
> Now, if you would not group by sex, how should Oracle present the results?
> Something like:
>
> 18 ? 35
> 19 ? 48
> 20 ? 12
>
> Oracle cannot do this, so really each column you select should be
mentioned.
>
> However, in your case you do not use any group by expression at all, so
why
> bother using group by? Simply
>
> order by U.oak_id, U.NameLast, U.NameFirst
>
> should do.
>
> Arjan.
>
>
Received on Fri Apr 23 1999 - 14:27:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US