【发布时间】:2022-01-10 16:48:48
【问题描述】:
好的,所以我遇到了一些问题,需要您的帮助。 这怎么能正常运行:
select salary from employees
where job_id = 'AD_PRES' and rownum <= 5
order by salary desc
这不是吗?
select * from employees
where
salary in
(
select salary from employees
where job_id = 'AD_PRES' and rownum <= 5
order by salary desc
)
我得到的错误是:00907. 00000 - "missing right parenthesis"
【问题讨论】:
-
我不是 Oracle 专家,但一般来说,您不能在派生表表达式中使用
ORDER BY。 -
@Johnny 检查这个:stackoverflow.com/questions/49269761/…
-
IN 子句是集合操作,。没有排序顺序,对父查询没有影响。
-
where子句在order by之前应用,因此排序对过滤没有影响 -
rownum 并不像您认为的那样。仅使用 FETCH FIRST 5 ROWS