请输出自从有用户作答记录以来,每月的试卷作答记录中月活用户数、
新增用户数、截止当月的单月最大新增用户数、截止当月的累积用户数。
结果按月份升序输出。
字段 start_month;mau;month_add_uv;max_month_add_uv;cum_sum_uv
select start_month,
count(distinct uid) mau,
sum(new_user) month_add_uv,
max(sum(new_user)) over(order by start_month) max_month_add_uv,
sum(sum(new_user)) over(order by start_month) cum_sum_uv
from
(select *, date_format(start_time,'%Y%m') start_month,
if(start_time=min(start_time)over(partition by uid),1,0) new_user
from exam_record)t1
group by start_month
order by start_month;