untuk meng-group data berdasar tahun dan bulan berikut contoh pemakaiannya di mysql:
misal tabel berita sbb:
id|kategori|tanggal|issue|
1|hardware|2008-01-13|cpu rusak
2|software|2008-01-20|office install
3|hardware|2008-01-23|tambah memory
4|hardware|2008-01-24|ganti HD
5|software|2008-02-03|install XP
6|hardware|2008-02-10|tambah RAM
7|software|2008-02-12|repair Ms. outlook
8|hardware|2008-03-02|ganti hardisk
9|hardware|2008-03-13|tambah memory
dst..
SELECT date_format(tgl_berita,'%Y-%m') as tanggal, nama_berita, count(nama_berita) as hitung from berita where tgl_berita > '2008-10-01' and nama_berita = 'act' group by year( tgl_berita ), month( tgl_berita ) , nama_berita
akan menjadi
bulan kategori jumlah
2008-01 hardware 3
2008-01 software 1
2008-02 hardware 2
2008-02 software 1
2008-03 hardware 2
2008-03 software 0
dst...
Sunday, February 01, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment