Reynier,
>Normally with PHP I add every field, I mean (eval1, eval2,
>eval3, eval4, eval5) and then divide this result by 5, like
>a average. I know that SQL can do this directly using AVG
>function but I don't know how. Can any help me?
AVG computes an average across rows. If I understand you correctly, you
want the average of five columns within each row? That would be ...
SELECT (eval1+eval2+eval3+eval4+eval5)/5 as mean FROM ...
and if you want the average of that ...
SELECT AVG( (eval1+eval2+eval3+eval4+eval5)/5 ) AS superavg FROM ...
PB
-----
Reynier Perez Mira wrote:
> Hi every:
>
> I have this table:
>
>
>
> smp_evaluacion
>
> ---------------
>
> id_evaluacion
>
> eval1
>
> eval2
>
> eval3
>
> eval4
>
> eval5
>
>
>
> This is for a rating system. I need to build a query for retrieve the best rating
> files. Normally with PHP I add every field, I mean (eval1, eval2, eval3, eval4, eval5) and
> then divide this result by 5, like a average. I know that SQL can do this directly using
> AVG function but I don't know how. Can any help me?
>
>
>
> Cheers and thanks in advance
>
>
>
>
>
> Reynier Pérez Mira
>
> 5to. año Ing. Informática
>
> Universidad de las Ciencias Informáticas
>
>
>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.472 / Virus Database: 269.9.0/852 - Release Date: 6/17/2007 8:23 AM
>
| Thread |
|---|
| • Help with AVG query | Reynier Perez Mira | 17 Jun |
| • Re: Help with AVG query | Peter Brawley | 17 Jun |