I have a table of survey answers, something like:
date | q1 | q2 |
12/12/10 | yes | no |
12/13/10 | no | no |
and I would like to
You could use:
select q1, q2, count(*)
from survey
group by q1, q2
Or, if you want to get those exact same results:
select count(case when q1 = 'Yes' then q1 else null end) as q1_yes,
count(case when q1 = 'No' then q1 else null end) as q1_no,
count(case when q2 = 'Yes' then q2 else null end) as q2_yes
from survey
Your implementation of "case" may vary, the important thing is you can set everything you don't want to null and it won't be counted by count() :)