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

全部评论

相关推荐

helloWord大王:这时候hr来个转人工我就真绷不住了
点赞 评论 收藏
分享
lyl秋招版:咱学校是这样的😭
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务