select *, sum(ct)over(partition by exam_id order by dt) from (select exam_id,date_format(start_time,'%Y%m') dt,count(start_time) ct from exam_record group by exam_id,dt) a
select *, sum(ct)over(partition by exam_id order by dt) from (select exam_id,date_format(start_time,'%Y%m') dt,count(start_time) ct from exam_record group by exam_id,dt) a