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: select a/avg(b) .... ?

Re: select a/avg(b) .... ?

From: James Lorenzen <james_lorenzen_at_allianzlife.com>
Date: Fri, 07 May 1999 13:50:20 GMT
Message-ID: <7gur2r$6rv$1@nnrp1.deja.com>


Sorry, the brain was not fully engaged in my previous post. This query will work.

select c1.a, c1.a/c2.avg_b from c c1, (select avg(b) avg_b from c) c2 ;

NOTE: It uses an inline view to get the average.

James

In article <7gup34$53i$1_at_nnrp1.deja.com>,   James Lorenzen <james_lorenzen_at_allianzlife.com> wrote:
> Sebastian; The AVG function is a group funtion and the "a" is not a group
> function. If you need to retrieve a list of all rows with "a/avg(b)"; then
> this will work:
>
> select c1.a/avg(c2.b) from c c1, c c2 ;
>
> HTH
> James
>
> In article <3732ACEC.F3A7560D_at_mpimp-golm.mpg.de>,
> Sebastian Kloska <kloska_at_mpimp-golm.mpg.de> wrote:
> > Hi
> >
> > I'm currently trying to solve a rather simple problem in Oracle8 end
> > got
> > stucked.
> >
> > What I have in mind is a query which would look like
> >
> > select a/avg(b) from c;
> >
> > Quite simple and I thing not so uncommon, but oracle complains about
> > the avg statement. In various SQL-handbooks they write that this is
> > not allowed because avg is an aggregate function with only one result
> > per select statment (or more if you add a group by).
> >
> > Nice explanation for theoretical database design, but how do I get
> > my results ?
> >
> > thank you
> >
> > Sebastian
> >
> > --
> > ======================================================================
> > Dr. Sebastian Kloska; Max-Planck Institut für Mol. Pflanzenphysiologie
> > Karl Liebknecht Straße 25; 14476 Golm; Tel: (+49 030) 84131542
> > * NEW MAIL ADDRESS * mailto:kloska_at_mpimp-golm.mpg.de
> >
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri May 07 1999 - 08:50:20 CDT

Original text of this message

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