SELECT DATE_FORMAT(date,'%M'),
SUM(if(Type = 'A', 1, 0)) AS A,
SUM(if(Type = 'B', 1, 0)) AS B,
SUM(if(Type = 'C', 1, 0)) AS C,
SUM(if(Type IS NOT NULL, 1, 0)) AS Total
FROM dates
GROUP BY DATE_FORMAT(date, '%Y%m')
ORDER BY date
This will not give the column totals but they are easily done in your script.
Hope this helps 😉