Hi,
I feel sure this should be possible, but can't quite figure it out. I have a database table that contains responses to a number of questions. Questions 77-83 are Yes/No questions, and I'd like to see, for each question, how many people answered yes and how many answered no. I can get the data I want like this:
mysql> select question, response_text, count(*) from response where question > 76 and question < 84 group by question, response_text;
+----------+---------------+----------+
| question | response_text | count(*) |
+----------+---------------+----------+
| 77 | FALSE | 5 |
| 77 | TRUE | 9 |
| 78 | FALSE | 2 |
| 78 | TRUE | 12 |
| 79 | FALSE | 10 |
| 79 | TRUE | 4 |
| 80 | FALSE | 4 |
| 80 | TRUE | 10 |
| 81 | FALSE | 12 |
| 81 | TRUE | 2 |
| 82 | FALSE | 12 |
| 82 | TRUE | 2 |
| 83 | FALSE | 13 |
| 83 | TRUE | 1 |
+----------+---------------+----------+
14 rows in set (0.01 sec)
However, the format I want it in would be more like:
Question | Count("Yes") | Count ("No")
I've tried Count (response_text="Yes") but that always gives 14 for all questions.
Can anyone help?
Thanks!
I feel sure this should be possible, but can't quite figure it out. I have a database table that contains responses to a number of questions. Questions 77-83 are Yes/No questions, and I'd like to see, for each question, how many people answered yes and how many answered no. I can get the data I want like this:
mysql> select question, response_text, count(*) from response where question > 76 and question < 84 group by question, response_text;
+----------+---------------+----------+
| question | response_text | count(*) |
+----------+---------------+----------+
| 77 | FALSE | 5 |
| 77 | TRUE | 9 |
| 78 | FALSE | 2 |
| 78 | TRUE | 12 |
| 79 | FALSE | 10 |
| 79 | TRUE | 4 |
| 80 | FALSE | 4 |
| 80 | TRUE | 10 |
| 81 | FALSE | 12 |
| 81 | TRUE | 2 |
| 82 | FALSE | 12 |
| 82 | TRUE | 2 |
| 83 | FALSE | 13 |
| 83 | TRUE | 1 |
+----------+---------------+----------+
14 rows in set (0.01 sec)
However, the format I want it in would be more like:
Question | Count("Yes") | Count ("No")
I've tried Count (response_text="Yes") but that always gives 14 for all questions.
Can anyone help?
Thanks!