Merctus use snapshot table calculate voucher summary report

just a month Ex.

we can get pre month data and concat to a complate report.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
                 
#1.get every monthly data
set @start_time = '2020-04-01 00:00:00';
set @end_time = '2020-04-30 23:59:59';
 
 
SELECT voucher_id, voucher_value
#DATE_FORMAT(expire_time,'%Y%m') months, SUM(voucher_value) AS amount
FROM voucher_issued_details_for_report
WHERE expire_time >= @start_time AND expire_time <= @end_time
and issue_time <= @end_time
and (submit_time > @end_time or reimburse_time is null)
and (void_time > @end_time or void_time is null)
 
 
select from voucher where voucher_id in (1036,1037,5261)
select from  voucher_issued_details_for_report where voucher_id in (1036,1037,5261)