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

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

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

#计算连续:当天-首日=排名-1  
with t1 as
(
select distinct author_id,answer_date,
min(answer_date) over(partition by author_id) mnd,
dense_rank() over(partition by author_id order by answer_date) as dr
from answer_tb
)
select author_id,author_level,max(dr)
from t1
inner join author_tb using(author_id)
where answer_date-mnd=dr-1 and dr>=3
group by author_id,author_level

全部评论

相关推荐

小红书 后端选手 n*16*1.18+签字费期权
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务