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条数据。
 
 
原文地址:https://www.cnblogs.com/2016-cxp/p/8654832.html