取连续出现3次的数字,可考虑: select distinct NUM from ( select NUM, rn_Id - rn_NUM as rn_ID_gp, count(1) as cnt from ( select NUM, row_number() over(order by Id) as rn_Id, row_number() over(partition by NUM order by Id) as rn_NUM from NUM_table ) a group by NUM, rn_Id - rn_NUM ) t where cnt >= 3