/*
BEGIN;
INSERT INTO official_deals_summary
	SELECT mem_no, med_no, course_no, mp, count(*), ins_ts::date as ins_date, payment_type_cd FROM official_deals
	WHERE ins_ts::date <= 'YESTERDAY'
	GROUP BY mem_no, med_no, course_no, mp, ins_date, payment_type_cd
	ORDER BY ins_date;
DELETE FROM official_deals WHERE ins_ts::date <= 'YESTERDAY';
COMMIT;
VACUUM ANALYZE;
*/