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

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

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

#rihuo == mei tian , distinct, yonghuzongshu
#xinyonghu zhanbi=dangtian xinyonghu /rihuo
with tnew as (
    select date(tb.in_time) as date_in_time,count(distinct tb.uid) as newnb
    from tb_user_log tb
    where not exists(
        select 1
        from tb_user_log tbefore
        where tb.uid=tbefore.uid and date(tbefore.in_time)<date(tb.in_time)
    )
    group by date(tb.in_time)
), 
tdate as (
    select tb.uid as uid,date(tb.in_time) as in_time
    from tb_user_log tb
    union
    select tb.uid,date(tb.out_time)
    from tb_user_log tb   )



select date(tb.in_time) as dt, count(distinct tb.uid) as dau,coalesce(round(avg(t.newnb)/count(distinct uid),2),0) as uv_new_ratio
from tdate tb left join tnew t on date(tb.in_time) = t.date_in_time 
group by date(tb.in_time)
order by date(tb.in_time) asc





全部评论

相关推荐

26想校招上岸的菜鸟:但是不可否认的是 leader想要3个 结果投了1000个 领导筛了100个面试 当leader找到了满意的3个 让他们继续二面 但是同时 其他的97个也会让你一面 因为已经约面了总不能毁面吧 因为leader也不确定那3个能不能过后面的面试,以及来不来 因此 这97个有一部分作为那3个的后续 剩下的 就是走个过场 面完就挂 这就是我个人认为的kpi面
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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