首页 > 数据库技术 > 详细

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

时间:2018-03-27 01:11:52      阅读:259      评论:0      收藏:0      [点我收藏+]
取得薪水最高的前五名员工
 
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条数据。
 
 

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

原文:https://www.cnblogs.com/2016-cxp/p/8654832.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!