题解|某乎问答最大连续回答问题天数>=3天的用户及其对应等级

某乎问答最大连续回答问题天数大于等于3天的用户及其对应等级

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

with t1 as
(select 
    distinct author_id,
    answer_date,
    dense_rank() over(partition by author_id order by answer_date) rn
from answer_tb),
t2 as 
(select 
    author_id,
    count(1) as day_cnt
from t1 
group by author_id, date_sub(answer_date, interval rn day)
having count(1) >= 3)
select 
    t2.author_id,
    author_level,
    day_cnt
from t2 
join author_tb using(author_id)
order by author_id

全部评论

相关推荐

08-28 20:36
门头沟学院 Java
点赞 评论 收藏
分享
头像
09-01 09:00
已编辑
四川旅游学院 运营
牛客55195891...:主要是专业不好,别的没毛病
牛客解忧铺
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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