Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

oracle - SQL Missing right parenthesis on order by statement

On the order by line, I get an error saying that it's missing a right parenthesis, but I have no idea why.

SELECT LAST_NAME AS "Last Name", DEPARTMENT_ID AS "Department Id", SALARY AS 
Salary
FROM EMPLOYEES JOIN DEPARTMENTS
USING(DEPARTMENT_ID)
WHERE SALARY IN (SELECT MIN(SALARY)
            FROM EMPLOYEES
            GROUP BY DEPARTMENT_ID, SALARY
            ORDER BY DEPARTMENT_ID);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

order by is not allowed in a subquery used on the right-hand side of an in condition. Oracle expected the closing parenthesis before order by.

It makes no sense to order the results of a subquery used in the in conditions.

Besides that, you probably want to group by dept_id only (why also by salary? that makes no sense).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...