Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: URGENT: sql group by clause has stopped working
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