题解|某乎问答最大连续回答问题天数>=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

全部评论

相关推荐

06-07 19:59
门头沟学院 C++
点赞 评论 收藏
分享
爱吃肉的伊登在写日记:好棒,27届简历能做成这个样子,但是第一个项目感觉cover住难度还是不小的,特别是二面的时候肯定要对分布式系统设计这一块儿有高出正常面试者的水平才行
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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