oracle ORA-00934: 00934. 00000 此处不允许使用组功能 - “此处不允许使用组功能”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41231651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-00934: group function is not allowed here 00934. 00000 - "group function is not allowed here"
提问by Rega Schardijn
The question is: give per office(kantoor) which have the total salary greater that 15000, give the average salary and the office name. use the inner join with using clausule
问题是:给出总工资大于 15000 的每个办公室(kantoor),给出平均工资和办公室名称。使用内连接和 using clausule
This is my current query:
这是我当前的查询:
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;
the query output is:
查询输出是:
ORA-00934: group function is not allowed here 00934. 00000 - "group function is not allowed here" *Cause:
*Action: Error at Line: 29 Column: 13
ORA-00934: 00934. 00000 - “此处不允许使用组功能” *原因:
*操作:第 29 行错误:第 13 列
回答by Siyual
You should use HAVING
for this:
您应该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;
回答by Md Aktaruzzaman
Should have use 'Group By' and 'Having' clause
应该使用“Group By”和“Having”子句