4 messages in com.mysql.lists.mysqlRe: Combining questions in one Select
FromSent OnAttachments
Jochen Haeberle07 May 1999 01:32 
Johan Engström07 May 1999 02:05 
Jochen Haeberle09 May 1999 22:21 
Luuk de Boer10 May 1999 08:51 
Subject:Re: Combining questions in one Select
From:Luuk de Boer (lu@wxs.nl)
Date:05/10/1999 08:51:04 AM
List:com.mysql.lists.mysql

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