33 - 连续出现的数字
-- 开窗函数lead(col,n) 统计窗口内往下第n行值
-- over(partition by xxx) 按照xxx所有行进行分组
-- over(partition by xxx order by aaa) 按照xxx分组,按照aaa排序
select distinct num as ConsecutiveNums
from(
select
num,
# 从当前记录获取前一行记录的num值,如果没有前一行,则返回null
lead(num,1) over(order by id) as a,
# 从当前记录获取后一行记录的num值,如果没有后一行,则返回null
lead(num,2) over(order by id) as b
from
logs
) t
where
num=a and num=b;