select start_month,count(distinct uid) as mau,
sum(new_day) as month_add_uv,
max(sum(new_day)) over(order by start_month) as max_month_add_uv,
sum(sum(new_day)) over(order by start_month) as cum_sum_uv
from(
select *,date_format(start_time,'%Y%m') as start_month,
if(start_time = min(start_time)over(partition by uid),1,0) as new_day from exam_record) as t1
group by start_month

先统计一下每个月新出现的人数new_day,然后使用窗口函数进行统计,