问题是:
给出总工资大于 15000 的每个办公室(kantoor),给出平均工资和办公室名称。使用内连接和 using clausule

这是我当前的查询:

SELECT      OFF.OFFICENR,
            OFF.NAME AS OFFICE,
            AVG(SAL)
FROM        OFFICE OFF INNER JOIN EMPLOYEE EMP USING (OFFICENR)
WHERE       SUM((SAL) >= 15000)                 **<---line 29**
GROUP BY    OFF.OFFICENR, OFF.NAME;

查询输出是:

最佳答案

您应该为此使用 HAVING:

SELECT      OFF.OFFICENR,
            OFF.NAME AS OFFICE,
            AVG(SAL)
FROM        OFFICE OFF
INNER JOIN  EMPLOYEE EMP USING (OFFICENR)
GROUP BY    OFF.OFFICENR, OFF.NAME
HAVING      SUM(SAL) >= 15000;

关于sql - ORA-00934 : group function is not allowed here 00934. 00000 - "group function is not allowed here",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41231651/

10-11 01:41