I am having trouble with a count col query I hope some one can help me with.
I have six questions and I would like to count how many "yes" answers in each col and then group by that col.
Here is my schema
||id || Q1|| Q2|| Q3||Q4 ||Q5 ||Q6||
||1 || yes || yes|| yes||no||yes||no
||2 || no || yes|| no||no||yes|| yes
||3 || no || yes|| no||no||yes|| yes
So essentially I would like 6 select queries but I can't figure out how to do this.
$result=mysql_query("SELECT Q1, count(*) as Q1_count FROM survey where Q1='yes' GROUP BY Q1");
How can I do this for all six columns and get a "count_alias" for each col? and can it be done with a single query?
thanks in advance to anyone who can help.