题解 | #最大连续回答问题天数大于等于3天的用户及其等级#

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

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

select
    b1.author_id,
    b2.author_level,
    b1.days_cnt
from (
    select 
        author_id,
        count(author_id) days_cnt
    from (
        select
            author_id,
            answer_date,
            dr,
            DATE_SUB(answer_date, INTERVAL dr DAY) date1
        from (
            select
                answer_date,
                author_id,
                dense_rank() over(partition by answer_date) dr
            from answer_tb
            group by answer_date,author_id
        ) t
    ) a
    where DATE_SUB(answer_date, INTERVAL dr DAY) = date1
    group by author_id
    having days_cnt >= 3 
) b1
inner join author_tb b2
on b1.author_id = b2.author_id

全部评论

相关推荐

有趣的牛油果开挂了:最近这个阶段收到些杂七杂八的短信是真的烦
点赞 评论 收藏
分享
尊嘟假嘟点击就送:加v细说,问题很大
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务