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

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

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

with t1 as(
    select distinct answer_date, tb1.author_id,author_level
    from answer_tb tb1
    left join author_tb tb2
    on tb1.author_id = tb2.author_id
),
t2 as (
    select * ,row_number() over(partition by author_id order by answer_date) rn
    from t1
),
t3 as (
    select *,date_sub(date(answer_date),interval rn day) dt from t2   
)
select author_id,author_level, count(*) days_cnt from t3  
group by  author_id,author_level
having days_cnt>=3

全部评论

相关推荐

投递拓竹科技等公司10个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-25 17:23
做完了怎么知道过没过呀
投递京东等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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