新登录用户的次日成功的留存率

牛客每个人最近的登录日期(三)

https://www.nowcoder.com/practice/16d41af206cd4066a06a3a0aa585ad3d

with t as(
    select 
        *,
        lead(date,1) over(partition by user_id order by date) nextdate
    from login
)

select 
    round(count(case when nextdate_mark>0 then 1 else null end)/count(user_id),3) p
from (
    select 
        user_id,
        sum(case when date_add(date,interval 1 day)=nextdate then 1 else null end) nextdate_mark
    from t
    group by user_id
) t2

把 t2 创建临时表就一直报错。。。。。

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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