如果我执行以下代码,我可以获得所需的输出;但在甲骨文面临着一个错误:
SELECT NAME
FROM STUD
WHERE ID IN (
SEL DISTINCT TAB1.ID
FROM (
SEL A.ID
, B.SALARY
FROM Fr A
INNER JOIN PACK B ON A.ID = B.ID
) AS TAB1
INNER JOIN (
SEL A.FRIEND_ID
, B.SALARY
FROM Fr A
INNER JOIN PACK B ON A.FRIEND_ID = B.ID
) AS TAB2
ON TAB2.SALARY > TAB1.SALARY
)
;
面对oracle中的以下错误: ORA-00907:缺少右括号
答案 0 :(得分:1)
您有两个错误:SEL
而非SELECT
以及使用AS
关键字的表别名,Oracle不支持
SELECT NAME
FROM STUD
WHERE ID IN (SELECT DISTINCT TAB1.ID FROM
(SELECT A.ID , B.SALARY
FROM
Fr A
INNER JOIN
PACK B
ON
A.ID = B.ID) TAB1
INNER JOIN
(SELECT A.FRIEND_ID , B.SALARY
FROM
Fr A
INNER JOIN
PACK B
ON
A.FRIEND_ID = B.ID
) TAB2
ON
TAB2.SALARY > TAB1.SALARY
)
除此之外,我认为您在内部查询中不需要DISTINCT
,因为您只在IN
子句中使用它