【发布时间】:2013-04-12 04:34:53
【问题描述】:
我在 oracle 中有一个员工表,其中包含姓名、薪水和其他详细信息。
我想拿第二高的薪水却拿不到。
这个很好用
with e_salary as (select distinct salary from employee)
select salary from e_salary
order by salary desc
并给出输出:
450000
61000
60000
50000
40000
30000
20000
6000
但是当我使用相同的查询来获取第二高的行时没有得到任何输出
select salary
from ( with e_salary as (select distinct salary from employee)
select salary from e_salary order by salary desc)
where rownum = 2
但是当我将rownum=2 替换为rownum<2 时,它会给出前两条记录的输出。请有人解释为什么rownum=2 不起作用
【问题讨论】: