题解 | #平均活跃天数和月活人数#

平均活跃天数和月活人数

https://www.nowcoder.com/practice/9e2fb674b58b4f60ac765b7a37dde1b9

SELECT 
    month,
    ROUND(AVG(active_days_per_user), 2) AS avg_active_days,
    COUNT(DISTINCT uid) AS mau
FROM (
    SELECT 
        DATE_FORMAT(submit_time, '%Y%m') AS month,
        uid,
        COUNT(DISTINCT DATE_FORMAT(submit_time, '%Y%m%d')) AS active_days_per_user
    FROM 
        exam_record
    WHERE 
        submit_time IS NOT NULL AND YEAR(submit_time) = 2021
    GROUP BY 
        DATE_FORMAT(submit_time, '%Y%m'), 
        uid
) AS subquery
GROUP BY 
    month;

#

高赞回答感觉不常用,这是通义千问写的

全部评论

相关推荐

点赞 评论 收藏
分享
11-01 20:03
已编辑
门头沟学院 算法工程师
Amazarashi66:这种也是幸存者偏差了,拿不到这个价的才是大多数
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务