ORA-56902: expect aggregate function inside pivot operation ORACLE 报错 故障修复 远程处理
文档解释
ORA-56902: expect aggregate function inside pivot operation
Cause: Attempted to use non-aggregate expression inside pivot operation.
Action: Use aggregate function.
等。
ORA-56902: expect aggregate function inside pivot operation 错误指出其缺少聚集函数,是一种PIVOT操作语法错误。
官方解释
常见案例
一般处理方法及步骤
1. 使用聚集函数将表进行聚合合并,比如如下:
SELECT emp_id, year, SUM(salary) as salary FROM emp GROUP BY emp_id,year;
2. 执行上一步后的结果,再执行PIVOT操作:
SELECT * FROM ( SELECT emp_id, year, sum(salary) FROM emp GROUP BY emp_id,year ) PIVOT( SUM(salary) FOR year IN (2010,2011,2012,2013,2014) );
以上两步,再加上PIVOT个性化设置就可以完成一个PIVOT操作,从而获取转换后的数据统计。