至少连续出现3(N)次的数字

数据

1
1
1
2
1
2
2
3
3
3
3
4

求解

select distinct number
from(select
number,
id,
lag(id,2) over(partition by number order by id) pre
from(
select
number,
row_number() over(partition by par order by par) id
from (select number,1 as par from series))
)
where id = pre+2;
Author: Tunan
Link: http://yerias.github.io/2020/12/16/%E5%9C%BA%E6%99%AF%E9%97%AE%E9%A2%98/4/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.