题解 | #平均活跃天数和月活人数#
平均活跃天数和月活人数
https://www.nowcoder.com/practice/9e2fb674b58b4f60ac765b7a37dde1b9
select
month,
round(count(distinct uid, day)/count(distinct uid),2) as avg_active_days,
count(distinct uid) as mau
from (
select uid, exam_id,
concat(substring(submit_time,1,4),substring(submit_time,6,2)) as month,
substring(submit_time,1,10) as day
from exam_record
where submit_time is not null and year(submit_time) = 2021
) as uniq
group by uniq.month