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

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

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

select
    dt,
    count(*) as dau,
    round(sum(if (dt = first_in_time, 1, 0)) / count(*), 2) as uv_new_ratio
from
    (
        select
            uid,
            dt,
            min(dt) over (
                partition by
                    uid
            ) as first_in_time
        from
            (
                select
                    uid,
                    date (in_time) as dt
                from
                    tb_user_log
                union
                select
                    uid,
                    date (out_time) as dt
                from
                    tb_user_log
            ) as info_tb
    ) as all_info_tb
    group by dt

全部评论

相关推荐

不愿透露姓名的神秘牛友
02-26 16:57
明天不下雨了:把第二个项目放第一个去,其他没什么问题,多投,这世道就这样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务