ORA-00937: not a single-group group function

有时候查询会遇到如下错误
 
SCOTT@PROD> select deptno,sum(sal) from emp;
select deptno,sum(sal) from emp
       *
ERROR at line 1:
ORA-00937: not a single-group group function
 
原因:这句话不会运行,因为deptno要求每行都显示,而sum要求统计后再显示,违反了原则。在有组函数的select中,不是组函数的列,一定要放在group by子句中。
 
正确语句:select deptno,sum(sal) from emp group by deptno;
posted @ 2019-01-22 21:26  高伟-林州  阅读(26506)  评论(0编辑  收藏  举报