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

全部评论

相关推荐

鬼迹人途:你去投一投尚游游戏,服务器一面,第一个图算法,做完了给你一个策略题,你给出方案他就提出低概率问题,答不上当场给你挂
点赞 评论 收藏
分享
想按时下班的我在等offer:我投测试也是这个情况,不知道咋办了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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