select distinct 
exam_id,date_format(start_time,'%Y%m') as m,
count(id) over(partition by exam_id, date_format(start_time,'%Y%m') ) as cnt_m,
count(id) over(partition by exam_id order by date_format(start_time,'%Y%m') )
as sum_cnt_m
from exam_record