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

Categories

0 votes
2.3k 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 Reply

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...