select *,sum(month_cnt) over (partition by exam_id order by start_month) as cum_exam_cnt
from
(select distinct exam_id,date_format(start_time,'%Y%m') as start_month,
count(*) over (partition by exam_id, date_format(start_time,'%Y%m') ) as month_cnt
from exam_record) a