select id,visit_date,people from # 第三步:连接主表信息,把筛选出来的结果匹配出来
(
select *,count(ranks) over (partition by ranks) as count from # 第二步: 统计差值的相同数量
(
select *,row_number() over(order by id) as rankss ,id - row_number() over(order by id) as ranks from stadium where people >99 # 第一步:筛选出来大于99的人数和排序、以及di和排序的差值
) t
) s
where count >=3; # 连续日大于等于3天的人
原文:https://www.cnblogs.com/Tdazheng/p/14920395.html