Alih-alih memperbarui jumlah per hari, minggu, dll. cukup MASUKKAN satu baris ke dalam tabel setiap kali aktivitas terjadi seperti ini:
insert into activities (activity_date, activity_info)
values (CURRENT_TIMESTAMP, 'whatever');
Sekarang laporan Anda sangat sederhana seperti:
select count(*) from activities
where activity_date between '2008-01-01' and '2008-01-07';
atau
select YEARWEEK(`activity_date`) as theweek, count(*)
group by theweek