Oracle只取第一行
- 伪列rownum,不能用于排序和分组,除非套一层select
select col01,col02 from table1 where rownum = 1;
select col02, col02 from (select col01, col02 from table1 order by col02 ) where rownum = 1;
- row_number() over(),必须套一层select
select * from (
select col01,col02,
row_number() over(partition by col03 order by col05 DESC) as num2
from table1 t1
) t2
where t2.num2=1;
【Oracle只取第一行】参考资料:
E11882_01/server.112/e41084/functions156.htm#i86310
- fetch first 版本12c才支持
select col01, col02
from table1
order by col03
fetch first 1 rows only;
- offset fetch next 版本12c才支持
select col02, col02
from table1
order by col03
offset 1 rows fetch next 1 rows only;
推荐阅读
- 午门传说
- 低头思故乡——只是因为睡不着
- 取名——兰
- 调取接口时报404错误(ID:16)
- 2018-09-03(李克富视角点评训练营81/90)|2018-09-03(李克富视角点评训练营81/90) 那只蛙从“井”爬出来又进入了“隧道”
- 早知道你是只飞鸟,我就应该把你关起来
- 使用协程爬取网页,计算网页数据大小
- 杀死一只知更鸟
- 只要有一台手机,人人都可以是摄影师
- 穷得只剩下一个人