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

最长连续登录天数

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

select user_id,max(cnt) as max_consec_days from(
select user_id,sub_result,count(*) cnt from(
select user_id,date_sub(fdate,interval rn day) sub_result from(
select fdate,user_id,row_number()over(partition by user_id order by fdate)rn from(
select fdate,user_id from tb_dau
)a
)b
)c group by user_id,sub_result
)d group by user_id






全部评论

相关推荐

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

创作者周榜

更多
牛客网
牛客企业服务