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

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

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

with t1 as(
    select
        dt,
        count(distinct uid) dau
    from(
        select 
            uid,
            date(in_time) dt
        from tb_user_log
        union
        select 
            uid,
            date(out_time) dt
        from tb_user_log
    ) a
    group by dt
),
t2 as(
    select
       date(first_dt) dt,
       count(uid) new_cnt
    from(
        select 
            uid, min(in_time) first_dt
        from tb_user_log
        group by uid
    ) b
    group by dt
)
select
    t1.dt,
    dau,
    round(ifnull(new_cnt/dau, 0), 2) uv_new_ratio
from t1 
left join t2 ON t1.dt = t2.dt
order by t1.dt

全部评论

相关推荐

03-11 16:05
运城学院 Java
程序员小白条:简历内容太多了,而且一段实习都没的情况下,写这么多,没啥说服力,反而让人觉得假
听劝,我这个简历该怎么改...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务