Formatee la marca de tiempo, luego agrupe por ella.
Agrupar por mes:
SELECT DATE_FORMAT(t.timestamp, "%Y-%m") AS "_Month", COUNT(*)
FROM yourtable as t
GROUP BY _Month;
Agrupar por Año:
SELECT DATE_FORMAT(t.timestamp, "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;
Si el campo de marca de tiempo se almacena como un valor de tiempo de Unix, simplemente ajuste FROM_UNIXTIME()
alrededor del campo:
SELECT DATE_FORMAT(FROM_UNIXTIME(t.timestamp), "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;