oracle报错-ORA-00937: not a single-group group function

执行SQL> select ename,sum_sal from (select ename,sum(sal) sum_sal from ( select * from emp)) group by ename;
select ename,sum_sal from (select ename,sum(sal) sum_sal from ( select * from emp)) group by ename
*
ERROR at line 1:
ORA-00937: not a single-group group function

原因:

句话不会运行,因为deptno要求每行都显示,而sum要求统计后再显示,违反了原则。在有组函数的select中,不是组函数的列,一定要放在group by子句中。

1、在有组函数的select中,不是组函数的列,一定要放在group by子句中。

问题解决:

select ename,sum_sal from (select ename,sum(sal) sum_sal from ( select * from emp) group by ename) ;

posted @ 2020-10-15 10:03  貔貅526  阅读(2699)  评论(0编辑  收藏  举报