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: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Fri, 09 Aug 2002 15:31:19 GMT
Message-ID: <3D53E041.3E30DC26@exesolutions.com>


blah wrote:

> In article <3D52FE9F.4D260EA9_at_noaa.gov>, Thomas Gaines <Thomas.Gaines_at_noaa.gov> wrote:
> >
> >--------------EF80E3403A11EEF94CE21647
> >Content-Type: text/plain; charset=us-ascii
> >Content-Transfer-Encoding: 7bit
> >
> >Mr. Blah -
> >
> >Your "group by" clause is useless here. Why are you even including
> >it? This clause is meaningful only when you have a single-group
> >group function in your statement. Something like this is more helpful:
> >
> >select owner, count (*)
> >from smith
> >where job = 'comp'
> >and branch = '9'
> >group by owner;
>
> >Tom
>
> Thanks Tom but how come the above query has been working fine for months and
> has suddenly started returning duplicates?
> This query also works on the development database?
>
> Thanks
>
> >
> >blah wrote:
> >
> >> Hi All,
> >>
> >> I can't figure this out.
> >>
> >> select owner
> >> from smith
> >> where job = 'comp'
> >> and branch = '9'
> >> group by owner;
> >>
> >> How can the above query return duplicates?
> >>
> >> Thanks,
> >> Wilk
> >
> >
> >
> >--------------EF80E3403A11EEF94CE21647
> >Content-Type: text/html; charset=us-ascii
> >Content-Transfer-Encoding: 7bit
> >
> ><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> ><html>
> >Mr. Blah -
> ><p>Your "group by" clause is useless here.&nbsp; Why are you even including
> ><br>it?&nbsp; This clause is meaningful only when you have a single-group
> ><br>group function in your statement.&nbsp; Something like this is more
> >helpful:
> ><p><tt><font color="#FF0000">select owner, count (*)</font></tt>
> ><br><tt><font color="#FF0000">from smith</font></tt>
> ><br><tt><font color="#FF0000">where job = 'comp'</font></tt>
> ><br><tt><font color="#FF0000">and branch = '9'</font></tt>
> ><br><tt><font color="#FF0000">group by owner;</font></tt>
> ><p>Tom
> ><p>blah wrote:
> ><blockquote TYPE=CITE>Hi All,
> ><p>I can't figure this out.
> ><p>select owner
> ><br>from smith
> ><br>where job = 'comp'
> ><br>and branch = '9'
> ><br>group by owner;
> ><p>How can the above query return duplicates?
> ><p>Thanks,
> ><br>Wilk</blockquote>
> >
> ><br>&nbsp;</html>
> >
> >--------------EF80E3403A11EEF94CE21647--
> >

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.

Daniel Morgan Received on Fri Aug 09 2002 - 10:31:19 CDT

Original text of this message

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