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

Home -> Community -> Usenet -> c.d.o.server -> Re: URGENT: sql group by clause has stopped working

Re: URGENT: sql group by clause has stopped working

From: Karl & Betty Schendel <schendel_at_kbcomputer.com>
Date: Fri, 09 Aug 2002 19:28:20 GMT
Message-ID: <schendel-444783.15282009082002@netnews.attbi.com>


In article <3D53E041.3E30DC26_at_exesolutions.com>,  Daniel Morgan <dmorgan_at_exesolutions.com> wrote:

> blah wrote:
>
> >> select owner
> > >> from smith
> > >> where job = 'comp'
> > >> and branch = '9'
> > >> group by owner;
> > >>
> > >> How can the above query return duplicates?
>
> That query never worked. You may have run it. It may have returned something.
> But it never
> worked as it is written in your original posting.
>
> GROUP BY only has meaning with an aggregating function such as COUNT, SUM, or
> AVG.
Stuff and nonsense. Let's not confuse "pointless" with "meaningless". The query as originally posted would better be done with DISTINCT, but it's certainly not wrong or meaningless. GROUP BY is defined to group rows that survive the WHERE clause according to the group by columns; it then reduces each "pile" of rows into a single row (group) per pile, evaluating any aggregates as it does so. If there are no aggregates to evaluate, the group by may be silly, but it's well defined.

As others have suggested, I imagine that there are trailing spaces or other hard-to-see characters in the OP's data. Received on Fri Aug 09 2002 - 14:28:20 CDT

Original text of this message

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