Formatez l'horodatage, puis regroupez-le.
Grouper par mois :
SELECT DATE_FORMAT(t.timestamp, "%Y-%m") AS "_Month", COUNT(*)
FROM yourtable as t
GROUP BY _Month;
Grouper par année :
SELECT DATE_FORMAT(t.timestamp, "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;
Si le champ d'horodatage est stocké en tant que valeur unixtime, enveloppez simplement FROM_UNIXTIME()
autour du terrain :
SELECT DATE_FORMAT(FROM_UNIXTIME(t.timestamp), "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;