ORA-00979:不是GROUP BY表达式 [英] ORA-00979: not a GROUP BY expression
问题描述
我想展示学生们工作的所有不同公司。
I am trying show all the different companies for which students work. However only companies where more than four students are employed should be displayed.
这是我到目前为止:
SELECT EMPLOYER, COUNT (STUDENT_ID)
FROM STUDENT
GROUP BY STUDENT_ID
HAVING COUNT (STUDENT_ID) >4;
我一直收到此消息:
ERROR at line 1:
ORA-00979: not a GROUP BY expression
b $ b
我不明白。我也尝试过这个早期:
I don't get it. I also tried this earlier:
SELECT STUDENT.EMPLOYER, COUNT (STUDENT.STUDENT_ID)
FROM STUDENT
GROUP BY STUDENT.STUDENT_ID
HAVING COUNT (STUDENT.STUDENT_ID) >4;
但似乎没有任何效果。任何帮助是赞赏。
but nothing seems to work. Any help is appreciated. I am on SQL*Plus if that helps.
推荐答案
尝试:
SELECT EMPLOYER, COUNT (STUDENT_ID)
FROM STUDENT
GROUP BY EMPLOYER
HAVING COUNT (STUDENT_ID) >4;
- 这将返回所有有超过4名学生的雇主的列表。
- this will return a list of all employers with more than 4 students.
在分组或包括聚合字段时,select语句应仅包括组中聚合或包含的字段$ c> clause - 在您现有的选择中,您在select子句中包括
EMPLOYER
,但不能按其分组或聚合。
When grouping or including aggregated fields, your select statement should only include fields that are either aggregated or included in the group by
clause - in your existing select, you are including EMPLOYER
in your select clause, but not grouping by it or aggregating it.
这篇关于ORA-00979:不是GROUP BY表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!