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

Home -> Community -> Usenet -> comp.databases.theory -> Re: Problem with the group statement...

Re: Problem with the group statement...

From: Larry Coon <larry_at_assist.org>
Date: Mon, 15 Jul 2002 15:45:10 -0700
Message-ID: <3D335076.4A60@assist.org>


Volker Hetzer wrote:

> Hi!
> I have trouble understanding the group statement. Here is
> a small example:
>
> create temporary table x (a int, b int);
> insert into x values(1,1);
> insert into x values(1,2);
> insert into x values(1,3);
> insert into x values(2,1);
> insert into x values(2,2);
> insert into x values(2,3);
> insert into x values(3,1);
> insert into x values(3,2);
> insert into x values(3,3);
> select * from x group by a;
>
> Now, this gives me:
> a b
> 1 1
> 2 1
> 3 1
>
> However, I had expected it to give the whole table.

Typically, when you use GROUP BY every item in the list of columns either appears in the GROUP BY clause or is an aggregate function. (I said "typically" because I thought that was a rule, but since it obviously works for you, I'm open to the possibility that this is something in the standard about which I am not aware.)

At the very least, this is not a canonical use of the GROUP BY. What, semantically, are you trying to accomplish with your query?

Larry Coon
University of California
larry_at_assist.org
and lmcoon_at_home.com Received on Mon Jul 15 2002 - 17:45:10 CDT

Original text of this message

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