SQL | Find all numbers that appear at least three times consecutively

SQL | Find all numbers that appear at least three times consecutively

 

select num from (

select id,num,

row_number() over(partition by num order by id) rn,

id-row_number() over(partition by num order by id) grp from fsq

) group by grp,num having count(distinct id)>=3;

Post a Comment

0 Comments