SQL缺少按语句排序的右括号 [英] SQL Missing right parenthesis on order by statement
本文介绍了SQL缺少按语句排序的右括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在逐行排序时,我收到一条错误消息,说它缺少右括号,但是我不知道为什么.
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);
推荐答案
order by
在in
条件右侧使用的子查询中是不允许的. Oracle期望order by
之前的右括号.
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
.
对在in
条件下使用的子查询的结果进行排序是没有意义的.
It makes no sense to order the results of a subquery used in the in
conditions.
除此之外,您可能只想group by dept_id
(为什么也按salary
键?这没有任何意义).
Besides that, you probably want to group by dept_id
only (why also by salary
? that makes no sense).
这篇关于SQL缺少按语句排序的右括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文