I have one table in the following format:
STATE SURVEY_ANSWER NC high NC moderate WA high FL low NC high
I am looking for one query that will give me the following result:
STATE HIGH MODERATE LOW NC 2 1 0 WA 1 0 0 FL 0 0 1
Unfortunately, these are the results I get:
STATE HIGH MODERATE LOW NC 3 1 1 WA 3 1 1 FL 3 1 1
Here is the code I'm using:
Select mytable.STATE, (SELECT COUNT(*) FROM mytable WHERE mytable.survey_answer = 'low' and state = mytable.state) AS low, (SELECT COUNT(*) FROM mytable WHERE mytable.survey_answer = 'moderate' and state = mytable.state) AS moderate, (SELECT COUNT(*) FROM mytable WHERE mytable.survey_answer = 'high' and state = mytable.state) AS high, FROM mytable GROUP BY mytable.state;
Although this and other forums were very helpful, I cannot understand what I'm doing wrong. PLEASE NOTE: I use Access so that CASE WHEN solutions do not work. Thanks for any advice.
source share