题解 | #最长连续登录天数#

最长连续登录天数

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

# select
# from 

select distinct user_id,const_num as "max_consec_days"
from(
select user_id, const_num, rank()over(partition by user_id order by const_num desc) as "fin_rank"
from(
select user_id, count(*) as "const_num"
from(
    select user_id,fdate,ranking,(day(fdate)-ranking) as "cont"
    from(
        select user_id,fdate,row_number()over(partition by user_id order by fdate) as 'ranking'
    from tb_dau
    where fdate between '2023-01-01' and '2023-01-31'
        )rank_t 
)const_t
group by cont,user_id
)fina_t
)fina_t2
where fin_rank = 1

全部评论

相关推荐

预计下个星期就能开奖吧,哪位老哥来给个准信
华孝子爱信等:对接人上周说的是这周
点赞 评论 收藏
分享
头像
11-07 01:12
重庆大学 Java
精致的小松鼠人狠话不多:签哪了哥
点赞 评论 收藏
分享
10-07 20:48
门头沟学院 Java
听说改名就会有offer:可能是实习上着班想到后面还要回学校给导师做牛马,看着身边都是21-25的年纪,突然emo了了
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务