Formatta il timestamp, quindi raggruppa per esso.
Raggruppa per mese:
SELECT DATE_FORMAT(t.timestamp, "%Y-%m") AS "_Month", COUNT(*)
FROM yourtable as t
GROUP BY _Month;
Raggruppa per anno:
SELECT DATE_FORMAT(t.timestamp, "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;
Se il campo timestamp è archiviato come valore unixtime, avvolgere semplicemente FROM_UNIXTIME()
in giro per il campo:
SELECT DATE_FORMAT(FROM_UNIXTIME(t.timestamp), "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;