In SQL, I have a column called "response", and the value can be 1 or 2. I need to generate an SQL query that counts the numbers 1 and 2 for each month. I have the following request, but it does not work:
SELECT MONTH(`date`), YEAR(`date`),COUNT(`answer`=1) as yes,
COUNT(`answer`=2) as nope,` COUNT(*) as total
FROM results
GROUP BY YEAR(`date`), MONTH(`date`)
Johnnny
source
share