Calculate total in table from query
Posted: Tue Apr 07, 2009 3:48 pm
Hi,
Doing this query I get total results from different result values.
Array
(
[0] => Array
(
[result_valueId] => 1
[total] => 15
)
[1] => Array
(
[result_valueId] => 2
[total] => 10
)
etc
Is there a way to sum up the totals from the array in my SQL statement or do I need to do another query or use PHP?
thanks
Code: Select all
$sql = "SELECT result_valueId, COUNT(result_valueId) AS total
FROM ufc_result GROUP BY result_valueId";
Array
(
[0] => Array
(
[result_valueId] => 1
[total] => 15
)
[1] => Array
(
[result_valueId] => 2
[total] => 10
)
etc
Is there a way to sum up the totals from the array in my SQL statement or do I need to do another query or use PHP?
thanks