假设我有一张桌子T_SWA。这是我准备好的陈述。
Select version
From (Select id, version, creator,
created_date ROW_NUMBER() OVER(order by created_date) cnt
From T_SWA
Where cnt=3 and id=35);
我需要从T_SWA表中选择第3个最新版本。任何人都可以在不使用ROW_NUM()
和OVER()
功能的情况下建议替换此查询吗?
答案 0 :(得分:0)
首先取三个最近,然后从这三个拿第一个。
select id, version, creator, created_date
from (
select id, version, creator, created_date
from T_SWA
where id = 35
order by created_date desc
fetch first 3 rows only
)
order by created_date
fetch first 1 row only;