# 1.思路:出现“截止当月”的关键词,应该要使用窗口函数的order by选项
# 2.求解
select exam_id, date_format(start_time, '%Y%m') start_month,
count(*) month_cnt, sum(count(*))over(partition by exam_id order by date_format(start_time, '%Y%m')) cum_exam_cnt
from exam_record
group by exam_id, date_format(start_time, '%Y%m');