Oracle 中sql语句中的取前n条数据


取得薪水最高的前五名员工
 
sql:
select * from (
select empno,ename,sal from emp order by sal desc)
where
rownum< 6;
 
注意:
select * from (
table )
where
rownum< 6;
取前n条数据,oracle中用rownum < m;
1:其中m-1 等于要取的条数
2:rownum 只能有 < ,<= ,没有 >
3: 如m为6,则取得是前5条数据。
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM