ORA-00979: not a GROUP BY expression

详细原因

分组 SQL 规则:SELECT 后非聚合函数字段,必须全部写入 GROUP BY 子句;只聚合部分字段会直接报错。

完整排查 & 错误 / 正确示例

错误写法:
select deptno,ename,sum(sal) from emp group by deptno; -- ename未分组
正确写法:
select deptno,ename,sum(sal) from emp group by deptno,ename;
优化:不需要展示的字段不要放到 select 后。
上一篇 route、ip route添加删除路由表命令,路由表永久化设置