Naformátujte časové razítko a poté jej seskupte.
Seskupit podle měsíce:
SELECT DATE_FORMAT(t.timestamp, "%Y-%m") AS "_Month", COUNT(*)
FROM yourtable as t
GROUP BY _Month;
Seskupit podle roku:
SELECT DATE_FORMAT(t.timestamp, "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;
Pokud je pole timestamp uloženo jako unixtime-value, stačí zabalit FROM_UNIXTIME()
kolem pole:
SELECT DATE_FORMAT(FROM_UNIXTIME(t.timestamp), "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;