Supponendo che la tua data sia un vero datetime
colonna:
SELECT MONTH(date), YEAR(date), id_publisher, COUNT(*)
FROM raw_occurrence_record
GROUP BY MONTH(date), YEAR(date), id_publisher
Puoi concatenare il tuo mese e anno in questo modo:
SELECT CONCAT(MONTH(date), '/', YEAR(date)) AS Month, id_publisher, COUNT(*)
FROM raw_occurrence_record
GROUP BY MONTH(date), YEAR(date), id_publisher
Per trovare i mesi in cui non ci sono record, avrai bisogno di una tabella delle date. Se non riesci a crearne uno, puoi UNION ALL
una tabella del calendario come questa:
SELECT a.year, a.month, b.id_publisher, COUNT(b.id_publisher) AS num
FROM
(SELECT 11 AS month, 2012 AS year
UNION ALL
SELECT 12, 2012
UNION ALL
SELECT 1, 2013
UNION ALL
SELECT 2, 2013) a
LEFT JOIN raw_occurence_record b
ON YEAR(b.date) = a.year AND MONTH(b.date) = a.month
GROUP BY a.year, a.month, b.id_publisher