题解 | #最大连续回答问题天数大于等于3天的用户及其等级#

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

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

with t1 as(
    select author_id,answer_date, rank()over(partition by author_id order by answer_date) rt
    from (
        select distinct author_id,answer_date
        from  answer_tb 
    )t
)
select author_id,author_level,max(cnt)
from
( 
    select author_id,count(*)cnt
    from t1
    group by  author_id,answer_date-rt
) t2 join author_tb at using (author_id)
group by author_id,author_level
having max(cnt)>=3
order by author_id

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 14:08
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-11 15:37
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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