i have a table below that records set responses from users for several different polls; results are stored in the responce column
CREATE TABLE IF NOT EXISTS `results` (
`poll_id` int(11) NOT NULL,
`response` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
`ip_number` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
KEY `poll_result` (`poll_id`,`poll_answer`)
)
Each poll has a unique Id; for example a poll asking users to choose between two cars would have poll_id of 1 BUT within the response column would have the responses for two possible cars e.g range or ford.
SELECT poll_answer FROM `results` WHERE poll_id = 1 AND poll_answer = 'Range'
i now need to draft an SQl query to determine the following;
total number and percentage of users, from poll 1, who chose Range Rover as their favorite car
total and percentage of users, from poll 1 , who chose ford.
total number of users who responded to poll 1**
i know how to get the total from a column but not how to get two total from the same column (with two different where clauses); and to then calculate the percentage.
SELECT Count(responce) FROM `results` WHERE poll_id = 1 AND response = 'range'