题解 | #统计作答次数#
平均活跃天数和月活人数
http://www.nowcoder.com/practice/9e2fb674b58b4f60ac765b7a37dde1b9
#注意活跃用户计算的时候时按照天来求和的,同一个用户可能在一天内活跃多次,需要去重
select date_format(start_time,'%Y%m')as month
,round(count(distinct uid, date_format(submit_time,'%Y%m%d'))/count(distinct if(score is not null,uid,null)) ,2)as avg_act_days
,count(distinct if(score is not null,uid,null)) as mau
from exam_record
where YEAR(submit_time) = 2021
group by 1