题解 | #2021年11月每天新用户的次日留存率#

2021年11月每天新用户的次日留存率

https://www.nowcoder.com/practice/1fc0e75f07434ef5ba4f1fb2aa83a450

with a as (
    select t3.uid,t3.first_date,t3.login_date,datediff(t3.login_date,t3.first_date) as remain_date
    from (
            select distinct t2.uid,date(out_time) as login_date,t2.first_date from tb_user_log t1
            left join
            (select uid, min(date(in_time)) as first_date from tb_user_log group by uid) t2
            on t1.uid = t2.uid
            where substr(date(in_time),1,7) = '2021-11' and substr(first_date,1,7) = '2021-11'
        )t3
)select
    a.first_date dt, round(sum(if(remain_date = 1,1,0)) / count(distinct a.uid) ,2) as uv_left_rate
from a
group by dt
order by dt;

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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