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

全部评论

相关推荐

牛客583549203号:腾讯还好,况且实习而已,实习生流动性很大,属于正常现象,记得和HR委婉解释
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务