I've been working on trying to solve the problem of calculating the average of a row of numbers in which some of the cells have a null value. I'm convinced there's no easy way to do this. I found an example on the net that I have been working from but I can't seem to get that to work either. The example is:
$sql = mysql_query("SELECT *,
(COALESCE(example, 0)
+ COALESCE(example2, 0)
+ COALESCE(example3, 0))
/
(3 -
(COALESCE(example - example, 1)
+ COALESCE(example2 - example2, 1)
+ COALESCE(example3 - example3, 1))
) AS row_avg FROM attrib1 WHERE recid=" .$recordid) or die(mysql_error());
I'm not sure what exactly this query is doing, and thus equally unsure of how to use it do my advantage. Any input would greatly appreciated.