试图了解SQL中GROUP BY
的用法
我已经多次遇到此错误,并且我无法确定核心以在以后的时间解决
SELECT d.department_name
FROM departments d
JOIN employees e
ON (d.department_id = e.department_id)
GROUP BY d.department_name
HAVING (SELECT COUNT(*) FROM employees) > 5
AND e.commission_pct IS NOT NULL;
ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action:
Error at Line: 7 Column: 5
答案 0 :(得分:2)
应具有按组分组的列,这是其构建方式。因此,让您可以汇总或操纵分组依据的列。分组错误的原因是您使用了子查询,而不是分组依据或聚合的列。
简而言之,拥有与在何处相似,但是拥有拥有使您可以过滤组中的记录,这与用于过滤整个表本身的记录的地方不同
SELECT d.department_name
FROM departments d
JOIN employees e
ON (d.department_id =
e.department_id)
Where
e.commission_pct IS NOT NULL
GROUP BY d.department_name
HAVING COUNT(*) > 5
;
答案 1 :(得分:1)
您的语法错误,条件应该在where子句中,并且不应重新选择值
public class JavaFxOriginText extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root, 100, 50, Color.WHITE);
primaryStage.setScene(scene);
primaryStage.show();
for(int i=0; i<5; i++) {
Text text = new Text(0, i*10, "Hello World! " + i);
text.setFill(Color.BLACK);
root.getChildren().add(text);
}
}
}