题解 | #每天的日活数及新用户占比#

每天的日活数及新用户占比

https://www.nowcoder.com/practice/dbbc9b03794a48f6b34f1131b1a903eb

select
    dt,
    count(*) as dau,
    round(sum(if (dt = new_time, 1, 0))/count(*),2) as uv_new_ratio
from
    (##求每个用户的活跃日期和注册日期
        select
            uid,
            dt,
            min(dt) over (
                partition by
                    uid
            ) as new_time
        from
            (
                select distinct
                    uid,
                    date (in_time) as dt
                from
                    tb_user_log
                union
                select distinct
                    uid,
                    date (out_time) as dt
                from
                    tb_user_log
            ) t1
    ) t2
group by
    dt
order by
    dt;

全部评论

相关推荐

点赞 评论 收藏
分享
03-11 14:28
浙江大学 设计
牛客小黄鱼:代入一下,独居女生会觉得有点可怕
点赞 评论 收藏
分享
我的名字是句号:接好运
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务