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

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

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

这个题应该很简单,不需要说明

select
    c.time,
    count(1) as dau,
    format(sum(case when c.rk = 1 then 1 else 0 end)/count(1),2) as uv_new_ratio
from 
(
    select
        b.uid,
        b.time,
        row_number() over(partition by b.uid order by b.time) as rk
    from 
    (
        select
            a.uid,date_format(a.in_time,'%Y-%m-%d') as time
        from tb_user_log a 
        union
        select
            a.uid,date_format(a.out_time,'%Y-%m-%d') as time
        from tb_user_log a
    ) b 
) c group by c.time

order by c.time

全部评论

相关推荐

01-14 19:01
吉首大学 Java
黑皮白袜臭脚体育生:加个项目吧,一般需要两个项目一业务一轮子呢,简历统一按使用了什么技术实现了什么功能解决了什么问题或提升了什么性能指标来写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务