# 请计算2021年每个月里试卷作答区用户平均月活跃天数
# avg_active_days和月度活跃人数mau,上面数据的示例输出如下:
# 2021年、每个月group by 、平均月活跃天数、月度活跃人数
select date_format(submit_time,'%Y%m') as `month`
,round((count(distinct uid,date_format(submit_time,'%Y%m%d'))/ count(distinct uid)),2)
,count(distinct uid) as `mau`
from exam_record
where year(start_time) = 2021 and score is not null
group by date_format(submit_time,'%Y%m')
# avg_active_days和月度活跃人数mau,上面数据的示例输出如下:
# 2021年、每个月group by 、平均月活跃天数、月度活跃人数
select date_format(submit_time,'%Y%m') as `month`
,round((count(distinct uid,date_format(submit_time,'%Y%m%d'))/ count(distinct uid)),2)
,count(distinct uid) as `mau`
from exam_record
where year(start_time) = 2021 and score is not null
group by date_format(submit_time,'%Y%m')



京公网安备 11010502036488号