#3个月时间节点
with a as(
select uid, m,submit_time
from 
(select er.uid,date_format(start_time,'%Y%m') as m,
    dense_rank() over (partition by er.uid order by date_format(start_time,'%Y%m') desc) as rk,
    submit_time
    from exam_record er) b
where rk<4  
)
    
select uid,count(submit_time) exam_complete_cnt
from a 
where uid not in (select uid
from a where submit_time is null)
group by uid
order by exam_complete_cnt desc,uid desc

易错点 近三个月是离散的三个月 示例中有提示