Format stempel waktu, lalu kelompokkan berdasarkan itu.
Kelompokkan berdasarkan Bulan:
SELECT DATE_FORMAT(t.timestamp, "%Y-%m") AS "_Month", COUNT(*)
FROM yourtable as t
GROUP BY _Month;
Kelompokkan berdasarkan Tahun:
SELECT DATE_FORMAT(t.timestamp, "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;
Jika kolom timestamp disimpan sebagai nilai unixtime, cukup bungkus FROM_UNIXTIME()
keliling lapangan:
SELECT DATE_FORMAT(FROM_UNIXTIME(t.timestamp), "%Y") AS "_Year", COUNT(*)
FROM yourtable as t
GROUP BY _Year;