Getting the average from multiple fields?
Posted: Mon May 28, 2007 6:28 pm
I am a new member and am seeking help on a problem. Mostly the problem is me because I don't know enough, but I am plugging away a trying to figure this out.
SELECT avg(p1) FROM `rounds` WHERE `g1`= -1;
I figured out that this line of code gives me the information I want. The problem is I have to get the info from 18 of these lines.
I tried
SELECT avg(p1) FROM `rounds` WHERE `g1`= -1;
SELECT avg(p2) FROM `rounds` WHERE `g2`= -1;
SELECT avg(p3) FROM `rounds` WHERE `g3`= -1;
SELECT avg(p4) FROM `rounds` WHERE `g4`= -1;
but all I get is the last one and not the total of all of them.
What is the best way to go about solving this.
I did this with PHPMyAdmin and will eventually need to put into my PHP scripts.
Thanks for any possible help. I can explain more if I haven't done a good job.
ofWES
SELECT avg(p1) FROM `rounds` WHERE `g1`= -1;
I figured out that this line of code gives me the information I want. The problem is I have to get the info from 18 of these lines.
I tried
SELECT avg(p1) FROM `rounds` WHERE `g1`= -1;
SELECT avg(p2) FROM `rounds` WHERE `g2`= -1;
SELECT avg(p3) FROM `rounds` WHERE `g3`= -1;
SELECT avg(p4) FROM `rounds` WHERE `g4`= -1;
but all I get is the last one and not the total of all of them.
What is the best way to go about solving this.
I did this with PHPMyAdmin and will eventually need to put into my PHP scripts.
Thanks for any possible help. I can explain more if I haven't done a good job.
ofWES