题解 | #某乎问答最大连续回答问题天数大于等于3天的用户及其对应等级#
某乎问答最大连续回答问题天数大于等于3天的用户及其对应等级
http://www.nowcoder.com/practice/e080f8a685bc4af3b47749ca3310f1fd
SELECT b.author_id,c.author_level,b.days_cnt
from author_tb c,
(
SELECT author_id,count(*)as days_cnt
from(
select distinct author_id,answer_date,DENSE_RANK()over(partition by author_id order by answer_date)
as rn
from answer_tb)a
group by author_id,date_add(answer_date, INTERVAL -rn day)
having days_cnt>=3
order by days_cnt )b
where b.author_id=c.author_id