resp_id visitorID surveyID questionID response answer userID
43 777 163 736 MS 0 1
42 777 163 736 Rohit 1 1
41 777 163 736 Virat 1 1
40 776 163 736 MS 1 1
39 776 163 736 Rohit 3 1
38 776 163 736 Virat 1 1
37 775 163 736 MS 0 1
36 775 163 736 Rohit 1 1
35 775 163 736 Virat 2 1
34 774 163 736 MS 2 1
33 774 163 736 Rohit 3 1
32 774 163 736 Virat 1 1
I want to count occurrence of each value of "answer" field in table respect to response
I have tried but did not get
SELECT count(answer) as answer_cnt
FROM `sg_finished_surveys`
WHERE resopnse = $q GROUP BY `answer`
Where $q
is equal to unique response value.