I have a table like this:
----------------------- | Name | Date | ----------------------- | John | July | | Carl | August | | John | July | | Robert | August | | Carl | September | | John | August | | Carl | August | | John | July | | Robert | September | | Carl | August | -----------------------
I would like to count the names divided by month.
SELECT Name, COUNT(IF(`Date` = 'July',1,0)) AS July, COUNT(IF(`Date` = 'August',1,0)) AS August, COUNT(IF(`Date` = 'September',1,0)) AS September, COUNT(*) AS All FROM table GROUP BY Name
I tried this query, but the count values are all the same