Leetcode Oracle-ORA-00923:未在预期位置找到FROM关键字
我正在尝试使用Oracle SQL解决此问题,但我不断遇到此错误-Leetcode Oracle-ORA-00923:未在预期位置找到FROM关键字,oracle,Oracle,我正在尝试使用Oracle SQL解决此问题,但我不断遇到此错误- ORA-00923:FROM关键字未在预期位置找到 问题链接- 到目前为止,我的解决方案-只是查询数据- with temp as ( select d.Name as Department, e.Name as Employee, e.Salary as Salary from employee e join department d on e.DepartmentId = d.
ORA-00923:FROM关键字未在预期位置找到
问题链接-
到目前为止,我的解决方案-只是查询数据-
with temp as
(
select d.Name as Department,
e.Name as Employee,
e.Salary as Salary
from employee e
join department d
on e.DepartmentId = d.Id
)
select *
, rank() over (partition by department order by salary desc) as rr
from temp
但如果我只是简单地运行它,那么它工作得很好-
with temp as
(
select d.Name as Department,
e.Name as Employee,
e.Salary as Salary
from employee e
join department d
on e.DepartmentId = d.Id
)
select *
from temp
如果我运行这个,那么它运行正常-
select department, employee, salary
from
(
select A.* , dense_rank() over (partition by department order by salary desc) as rr
from
(
select d.Name as Department,
e.Name as Employee,
e.Salary as Salary
from employee e
join department d
on e.DepartmentId = d.Id
) A
) B
where rr <= 3
在Oracle中?如果只需要选择所有列,则不带别名的
*
就可以了。但是,如果需要在需要选择表的所有列的任何位置提供表的别名,请使用*
以及select
子句中的另一个表达式
with TEMP AS
( SELECT
COL1,
COL2
FROM table )
, TEMP1 AS
(SELECT
T.*, -- alias here
"hello" AS COL3
FROM TEMP T
)
select * FROM TEMP1;
with temp as
(
select d.Name as Department,
e.Name as Employee,
e.Salary as Salary
from employee e
join department d
on e.DepartmentId = d.Id
)
select T.* -- alias here
, rank() over (partition by department order by salary desc) as rr
from temp T;
with TEMP AS
( SELECT
COL1,
COL2
FROM table )
, TEMP1 AS
(SELECT
T.*, -- alias here
"hello" AS COL3
FROM TEMP T
)
select * FROM TEMP1;
with temp as
(
select d.Name as Department,
e.Name as Employee,
e.Salary as Salary
from employee e
join department d
on e.DepartmentId = d.Id
)
select T.* -- alias here
, rank() over (partition by department order by salary desc) as rr
from temp T;