Here is a very simplified version of what I am trying to do...
Code:
SELECT
COUNT(*) AS qty,
AVG(p1) AS val1,
AVG(p2) AS val2, 
AVG(p3) AS val3
FROM `test_db`
WHERE cid = 5
This query finds all records in my "test_db" with a "cid" value of 5. It then counts how many records, and then averages each column so I can display as needed...

Example Results
qty = 7
val1 = 3.2
val2 = 4.3
val3 = 3.1

MY PROBLEM:
Now I need to take all the average values (val1, val2 & val3 but not the qty) and get the average from those and save it within another value (eg: totalaverage)...
I would like to do this within the query if possible, and not use any php scripting for that final calculation.

The results I would like are:
qty = 7
val1 = 3.2
val2 = 4.3
val3 = 3.1
totalaverage = 3.53

One additional problem. It is possible that some of the values (val1, val2, val3) are actually null, therefore it will not be as easy as just adding/dividing.

Is there any way to do this within MySQL? Or must I resort to doing that final calculation with PHP?