select distinct m,m_uv,new_m_uv,
max(new_m_uv) over(order by m asc) as max_new_m_uv,
sum(new_m_uv) over(order by m asc) as cum_m_uv
from(
select distinct m,
count(uid) over(partition by m) as m_uv,
count(if(m=min_m,uid,null)) over(partition by m) as new_m_uv
from(
select distinct uid,date_format(start_time,'%Y%m') as m,
min( date_format(start_time,'%Y%m') ) over(partition by uid) as min_m
from exam_record )a)b