--方法一: SELECT A.id, to_char(A.visit_date, 'yyyy-MM-dd') AS visit_date, A.people FROM stadium A WHERE A.people >= 100 AND ((A.id - 1IN ( SELECTidFROM stadium WHERE people >= 100 ) AND A.id - 2IN ( SELECTidFROM stadium WHERE people >= 100 )) OR (A.id - 1IN ( SELECTidFROM stadium WHERE people >= 100 ) AND A.id | 1IN ( SELECTidFROM stadium WHERE people >= 100 )) OR (A.id | 1IN ( SELECTidFROM stadium WHERE people >= 100 ) AND A.id | 2IN ( SELECTidFROM stadium WHERE people >= 100 )) ) ORDERBY A.id --方法二:使用分析函数 WITH tmp AS ( SELECTid,last_id,next_id FROM ( select people,LAG(id,1,null)over(orderbyid) last_id,id,LEAD(id,1,null)over(orderbyid) next_id from stadium WHERE people >=100 ) A WHERE (A.id=A.last_id | 1AND A.id=A.next_id - 1) ) SELECTid,SUBSTR(visit_date,1,10) visit_date,people FROM stadium WHEREid =any( SELECTidFROM tmp UNION SELECT last_id FROM tmp UNION SELECT next_id FROM tmp )ORDERBYid