题目
https://leetcode.cn/problems/consecutive-numbers/description/
# row_number() over([partition by value_expression,...n] order by columnName)
#1.最外层 查结果表 得到 num
#select distinct num as ConsecutiveNums from result;
#2. 至少连续出现三次的数字
#select num2, count(1) from temp_table group by num2,z having count(1)>=3; // 出现三次以上
#// 连续的 重新生成id y, 按 num分组,组内再排序x, y-x 相等表示是连续的一组; 组内排序
#select id, num, (row_number() over(order by id) -row_number() over(partition by num order by id)) as SerialNumberSubGroup from Logs;
# 整合
select distinct num as ConsecutiveNums from (
select num, count(1) from (
select id, num, (row_number() over(order by id) -row_number() over(partition by num order by id)) as SerialNumberSubGroup from Logs
) sub group by num, SerialNumberSubGroup having count(1)>=3
) as result;