找到连续的数子


table1 中 找出连续出现三次的数
id num
1 1
2 1
3 1
4 2
5 1
6 1
7 2

select
distinct num
from(
select
num,
lag(num,1,null) over (order by id asc) as num1,
lag(num,2,null) over (order by id asc) as num2,
from table1
) t1 where num = num1 and num1 = num2


posted on 2022-12-05 20:40  大鹏的鸿鹄之志  阅读(17)  评论(0编辑  收藏  举报