SQL Developer - SQL错误:ORA-00909:参数数量无效

时间:2015-04-23 14:12:35

标签: sql oracle

在HR模式中,我想列出所有有薪水的员工。不同国家的部门的平均工资,按国家和部门名称分组

SELECT E.FIRST_NAME , S.COUNTRY_NAME, S.DEPARTMENT_NAME, S.AVG_SALARY, E.SALARY 
FROM EMPLOYEES E JOIN (SELECT COUNTRY_NAME, DEPARTMENT_NAME, ROUND(AVG(SALARY,0) AS "AVG_SALARY", DEPARTMENT_ID
                       FROM (SELECT SALARY, COUNTRY_NAME, DEPARTMENT_NAME, DEPARTMENT_ID
                             FROM EMPLOYEES JOIN DEPARTMENTS USING (DEPARTMENT_ID)
                             JOIN LOCATIONS USING (LOCATION_ID)
                             JOIN COUNTRIES USING (COUNTRY_ID)
                             )
                       GROUP BY COUNTRY_NAME, DEPARTMENT_NAME, DEPARTMENT_ID
                       )   S ON (E.DEPARTMENT_ID=S.DEPARTMENT_ID)
WHERE E.SALARY< S.AVG_SALARY AND E.DEPARTMENT_ID = S.DEPARTMENT_ID
GROUP BY COUNTRY_NAME, DEPARTMENT_NAME, AVG_SALARY, FIRST_NAME, SALARY
ORDER BY COUNTRY_NAME;

1 个答案:

答案 0 :(得分:2)

确保符合您的括号。

ROUND(AVG(SALARY,0)

应该是:

ROUND(AVG(SALARY),0)