Jika Anda menyimpan the_date
sebagai integer, Anda harus terlebih dahulu mengonversinya menjadi datetime menggunakan FROM_UNIXTIME
fungsi:
SELECT SUM(`amount_sale`) as total
FROM `sales`
WHERE `payment_type` = 'Account'
GROUP BY WEEK(FROM_UNIXTIME(`the_date`))
PERBARUI :
Juga, Anda mungkin ingin menampilkan nomor minggu,
SELECT CONCAT('Week ', WEEK(FROM_UNIXTIME(`the_date`))) as week_number,
SUM(`amount_sale`) as total
FROM `sales`
WHERE `payment_type` = 'Account'
GROUP BY WEEK(FROM_UNIXTIME(`the_date`))