I have the following query:
SELECT AVG (q1) AS q1, AVG (q2) AS q2, AVG (q3) AS q3
FROM thotels_results
WHERE brand IN ('ABC','EFG','XYZ')
AND date = 'NOV2010' GROUP BY brand;
I LOOP through the results and have dumped out the array using var_dump, the output is below:
array
'q1' => string '8.1724' (length=6)
'q2' => string '8.2414' (length=6)
'q3' => string '8.2414' (length=6)
array
'q1' => string '8.7714' (length=6)
'q2' => string '8.8429' (length=6)
'q3' => string '8.1643' (length=6)
array
'q1' => string '8.6009' (length=6)
'q2' => string '8.5686' (length=6)
'q3' => string '7.8528' (length=6)
What I would like to do is, somehow, add each of the q1's together and divide by 3 to give me an average, then the same for q2 and the same for q3:
8.1724 + 8.7714 + 8.6009 / 3 = 8.5149
I'm not sure how to access the information stored in the array - thanks in advance.
Homer.