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

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

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

with active as (
    select 
        uid,
        date(in_time) as dt,
        min(date(in_time))over(partition by uid) as new_d
    from 
        tb_user_log
    union
    select 
        uid,
        date(out_time) as dt,
        min(date(in_time))over(partition by uid) as new_d
    from 
        tb_user_log
)

select 
    dt,
    count(distinct uid) as dau,
    round(sum(case when dt = new_d then 1 else 0 end)/count(distinct uid),2) as uv_new_ratio
from active 
group by dt
order by dt

全部评论

相关推荐

12-15 12:50
河北工程大学
sta666:我也是这个国际商业化的,三天,一天一面,就通过了,不过我是后端实习生,好好面感觉能过。
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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