题解 | #平均活跃天数和月活人数#
平均活跃天数和月活人数
http://www.nowcoder.com/practice/9e2fb674b58b4f60ac765b7a37dde1b9
SELECT DATE_FORMAT(submit_time, '%Y%m') month, ROUND( COUNT(DISTINCT uid, DATE_FORMAT(submit_time, '%y%m%d')) / COUNT(DISTINCT uid), 2 ) avg_active_days, COUNT(DISTINCT uid) mau FROM exam_record WHERE submit_time IS NOT NULL AND YEAR(submit_time) = 2021 GROUP BY DATE_FORMAT(submit_time, '%Y%m');