SELECT 
	CONCAT(DATE_FORMAT(LAST_DAY(CURDATE() - INTERVAL 1 DAY),'%Y%m%d'),TRIM(KODE_GROUP1)) AS id
    ,LAST_DAY(CURDATE()) AS tanggal
	,TRIM(KODE_GROUP1) AS kode_marketing_tabungan
    ,SUM(SALDO_AKHIR) AS saldo_akhir
FROM tabung
WHERE STATUS_AKTIF NOT IN ('3')
AND KODE_GROUP1 <> ''
AND KODE_GROUP1 <> '0'
GROUP BY TRIM(KODE_GROUP1)
