Query help Sum & count MYSQL

admin

Administrator
Staff member
$sql = "SELECT antwoord, count(*) AS cnt FROM voter_resultaat WHERE vraag='$voter_id' GROUP BY antwoord ORDER BY cnt DESC";

This gives me the result per antwoord (answer)...

Can it be done so that the count gives me the percentage of the total count of all answers? (i hope this makes sence)

I would also like to have the query to get the SUM of all the results.

I tryed with:
$sql = "SELECT SUM(antwoord) AS total FROM voter_resultaat WHERE vraag='$voter_id' GROUP BY vraag";

But that did not work...
Please help me out.
Kind regards,
Gerry
 
Back
Top