方法一:查询结果相减
select * from (select * from ss ORDER BY CANTIME desc )
where rownum<=2
minus
select * from (select * from ss ORDER BY CANTIME desc )
where rownum<=1
方法二:用rownum来查询区分记录
select *
from (select t.*, rownum as rn
from B_XXX_PDF t
where writid = ‘1254565545555’
and pdfzt = ‘0’
order by createtime desc)
where rn = 2
方法三:子查询实现
select
reemployeeid, scantime
reemployeeid, scantime
from
(
select
t.reemployeeid,
t.scantime,
RANK() OVER(
order
by
scantime)
as
RowNumber
from
tab t) b
where
b.RowNumber + 1 = (
select
max
(RowNumber)
from
(
select
t.reemployeeid,
t.scantime,
RANK() OVER(
order
by
scantime)
as
RowNumber
from
tab t))
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/4370.html