题解 | #某乎问答最大连续回答问题天数大于等于3天的用户

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

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

with data as
(select distinct
b.author_id,b.answer_date,
dense_rank() over(
    partition by b.author_id
    order by b.answer_date
) as rn
from 
author_tb as a
right join answer_tb as b on  a.author_id=b.author_id
group by b.author_id,b.answer_date),

 data2 as (
select 
author_id,count(*) as r
from
data
group by
author_id,
date_sub(answer_date,interval rn day)
having count(*)>=3)


select 
data2.author_id,

author_tb.author_level,r

from data2 
left join author_tb on data2.author_id=author_tb.author_id

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-07 20:19
真是乐了:模版不太好 而且字太密了项目说的太细碎
点赞 评论 收藏
分享
专心打鱼:互联网搬运工,贴子都要偷
点赞 评论 收藏
分享
京东 京东零售 总包63w
起床了的佳佳:要是我看前面就直接决定了, 你还分析,羡慕死了
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务