For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > November 2004 > Re: Newbie PHP MySQL percentage









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Newbie PHP MySQL percentage
Hilarion

2004-11-10, 8:56 pm

Something like this below should do the job.

SELECT count(*) AS total_count
FROM poll_answers
WHERE poll_id = $poll_id


SELECT answer_id, ( count(*) * 100 / $total_count ) AS answers_percentage
FROM poll_answers
WHERE poll_id = $poll_id
GROUP BY answer_id

Hilarion


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com