List:General Discussion« Previous MessageNext Message »
From:Luuk de Boer Date:January 1 1970 12:00am
Subject:Re: Combining questions in one Select
View as plain text  
On 10 May 99, at 7:21, Jochen Haeberle wrote:

> Hi,
> 
> At 12:06 Uhr +0300 07.05.1999, Johan Engstr–m wrote:
> > > BTW.: Is there really no average() funktion in MySQL? I could not find
> > > one in the manual.
> >
> >Straight from the manual:
> >
> >7.3.12 Functions for use with GROUP BY clauses
> >
> >AVG(expr)
> >    Returns the average value of expr.
> 
> You are right. I could not find it because avg(expr) does not show up in
> the TOC-page.
> 
> This way I can easily get all average votes of different users:
> 
> Select avg(vote) from votes gropu by voter_id;
> 
> But I am still unable to get the sum of all votes, as using 
> sum(avg(vote)) gives an ERROR 1111: Invalid use of group function.
> 
> As every subject has another ID, I could use an Order By on this to 
> create a sum, but it does not work either.
> 
> Is there a way to get a one line result for the above querry that 
> shows the sum of all the averages???
> 

did you tried something like:

select sum(avg(vote)) as totalnr from x order by totalnr

Greetz...

Luuk
Thread
Combining questions in one SelectJochen Haeberle7 May
  • Re: Combining questions in one Selectjohan.engstrom7 May
    • Re: Combining questions in one SelectJochen Haeberle10 May
      • Re: Combining questions in one SelectLuuk de Boer10 May