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

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

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

如何求连续打卡,以及连续签到得金币等问题就是用打卡日期减去该日期的排名,相减相同的为一个连续打卡的分组,然后记数即可

select id.author_id,author_level,cnt
from (
SELECT author_id,first_day,count(distinct answer_date) as cnt
from
(SELECT DENSE_RANK() over(partition by author_id 
                             order by answer_date) as rk,
    TIMESTAMPADD(day,-DENSE_RANK() over(partition by author_id 
                             order by answer_date)+1,answer_date) AS first_day,
    author_id,answer_date
    from answer_tb) base
group by author_id,first_day
having cnt>=3) id left join author_tb using(author_id)
全部评论

相关推荐

05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
实习,投递多份简历没人回...
点赞 评论 收藏
分享
昨天 15:12
门头沟学院 运营
点赞 评论 收藏
分享
评论
6
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务