0
我想編寫一個查詢,以獲取有關誰第一個聘請各部門中的員工的信息我寫下面的查詢,我得到「ORA-00904:‘RN’:無效的標識符00904
「ORA-00904: 「RN」:無效的標識符 00904. 00000 - 「%s的:無效的標識符」
查詢:
select employee_id, department_id, first_name, last_name, hire_date,
ROW_NUMBER() over (partition by department_id order by hire_date) as rn
from employees
where rn =1;
能否請您給我解釋一下爲w rong「標識符?
添加查詢文本而不是鏈接到圖像 – Jens
這是操作問題的順序。 SELECT在引擎的where子句之後執行。所以在執行時,RN對where子句是未知的。像@GordonLinoff所說明的那樣解決使用子查詢或CTE的問題。 [有關先前堆棧問題的更多信息](http://stackoverflow.com/questions/17403935/what-is-the-order-of-execution-for-this-sql-statement) – xQbert