题解 | 平均活跃天数和月活人数
平均活跃天数和月活人数
https://www.nowcoder.com/practice/9e2fb674b58b4f60ac765b7a37dde1b9
select month,round(sum(num)/count(uid),2) as avg_active_days,count(uid) as mau from( select month,uid,count(distinct date(start_time)) num from( select *,date_format(date(start_time),'%Y%m') as month from exam_record where score != '(NULL)' and left(start_time,4) = '2021') as t1 group by month,uid) as t2 group by month
先计算每月每个用户的活跃次数
再计算别的