Lag和Lead函数可以在一次查询中取出同一字段的前N行的数据和后N行的值 select * from (select text, lag(text, 1) over(order by rownum), lag(text, 2) over(order by rownum), lead(text, 1) over(order by rownum), lead(text, 2) over(order by rownum) from alert_log) where text like 'ORA-%'