select SEAT,L_SEAT,rowid,L_rowid from (select *,LAG(SEAT) OVER(ORDER BY SEAT*1) L_SEAT,LAG(STATUS) OVER(ORDER BY SEAT*1) L_STATUS,LAG(rowid) over(order BY seat*1) L_rowidfrom ks3) aWHERE status='未预订' AND L_STATUS='未预订' and rowid=L_rowid
select SEAT,L_SEAT from (select *,LAG(SEAT) OVER(ORDER BY SEAT) L_SEAT,LAG(STATUS) OVER(ORDER BY SEAT) L_STATUS from ks2) aWHERE status='未预订' AND L_STATUS='未预订'