1、时间函数
2、窗口函数
2.1 连续两次作答问卷的最大时间窗 lead () over (partition by )
with temp as
(select dc.uid, max(dc.diff) as days_window from
(select uid,
start_time,
datediff(lead(start_time) over (partition by uid order by start_time), start_time)+1 as diff
from exam_record
where year(start_time)=2021) as dc
group by dc.uid
having count(distinct date_format(start_time, "%Y-%m-%d"))>=2),
2、排序 Rank/dense_rank () over (partition by order by)