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

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

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

select 
    au.author_id author_id
    ,au.author_level
    ,t1.cnt days_cnt
from
(
select 
    id
    ,k
    ,count(dt) cnt
from 
(select 
    distinct author_id id
    ,answer_date dt
    ,dense_rank()over(partition by author_id order by answer_date) r 
    ,answer_date-dense_rank()over(partition by author_id order by answer_date) k
from 
    answer_tb 
 ) t0
group by 
    id 
    ,k 
having
    count(dt)>=3 
) t1
left join 
    author_tb au 
on 
    au.author_id=t1.id
order by 
    author_id

全部评论

相关推荐

有趣的牛油果开挂了:最近这个阶段收到些杂七杂八的短信是真的烦
点赞 评论 收藏
分享
10-21 23:48
蚌埠坦克学院
csgq:可能没hc了 昨天一面完秒挂
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务