I am using DW to create record set that calculates the percentage from a table grouped by hospital name. I need to get the average of the percentage (by summation of the percentage divided by the number of hospital). I have only one table.
mysql_select_db($database_localapconnect, $localapconnect);
$query_Recordset1 = "SELECT COUNT(IF(ap_intervalname = 'Less than or equal to 12 hours', ap_intervalname, NULL))/ COUNT(ap_intervalname) *100 AS 'percent' FROM maintble GROUP BY `hospitalname`";
$Recordset1 = mysql_query($query_Recordset1, $localapconnect) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
while($row_Recordset1 = mysql_fetch_array($Recordset1)) {
print_r( $row_Recordset1['percent'].'<br>');
}
print_r ($totalRows_Recordset1).'<br>' ;
echo sum($row_Recordset1['percent'])/$totalRows_Recordset1;
result:
83.0189
98.0000
86.2745
68.0365
94.9686
78.4314
6
I get the following error:
Fatal error: Call to undefined function sum() in C:\wamp\www\ap_database\Untitled-1.php on line 49