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

平均活跃天数和月活人数

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-08 17:36
诺瓦科技_HR
点赞 评论 收藏
分享
过往烟沉:我说什么来着,java就业面就是广!
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务