1.利用分析函数
select *
from (select t.*, row_number() over(order by line_id desc) rn
from XXXX t
where t.header_id = 661)
where rn = 2;
2.利用rownum
select *
from (select t.*, rownum rn
from (select paal.*
from XXXX paal
where paal.header_id = 661
order by paal.line_id desc) t)
where rn = 2;