gpt4 book ai didi

sql - ORA-00934 : group function is not allowed here 00934. 00000 - "group function is not allowed here"

转载 作者:行者123 更新时间:2023-12-01 09:49:25 25 4
gpt4 key购买 nike

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

这是我当前的查询:

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;

查询输出为:

ORA-00934: group function is not allowed here 00934. 00000 - "group function is not allowed here" *Cause:
*Action: Error at Line: 29 Column: 13

最佳答案

您应该为此使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com