题解 | #最大连续回答问题天数大于等于3天#

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

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

select 
    t1.author_id,
    author_level,
    days_cnt
from(
    select 
        author_id,
        1+count(1) as days_cnt
    from(
        select 
            author_id,
            answer_date as dt,
            lead(answer_date,1) over (partition by author_id order by answer_date asc) as ld
        from 
            answer_tb) as a
    where 
        datediff(dt,ld) = -1
    group by 1
    having count(1) >= 2) as t1
left join author_tb as t2
on t1.author_id = t2.author_id

全部评论

相关推荐

03-31 16:42
已编辑
郑州西亚斯学院 后端
Java抽象带篮子:你简历少了几个模块看上去就感觉信息很少,简历怎么写可以看看我发的帖子
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务