# 难点:
# 1、设置连续登录标志:(1)按照时间排序;(2)将登录时间减去排序,生成连续登录标志
# 2、连续登录处理:由于存在同一个人一天内登陆多次,因此需要去重
select t5.author_id,t5.author_level,t5.days_cnt from (
select t4.author_id,t4.author_level,t4.sb,count(*) as days_cnt 
from (
select DATE_add(t3.answer_date, interval -t3.rank_date day) as sb
,t3.author_id,t3.author_level from (
select distinct t1.answer_date,t1.author_id,t2.author_level 
,dense_rank() over(partition by t1.author_id order by t1.answer_date) as rank_date 
from answer_tb as t1 left join author_tb as t2 
on t1.author_id = t2.author_id ) t3 order by t3.author_id,t3.answer_date
) t4 
group by t4.author_id,t4.author_level,t4.sb having count(*) >=3 
order by t4.author_id )t5