SELECT empno,ename,
SUM(DECODE(deptno,'10',sal,0)) 部门10,--这里使用max,min都可以
SUM(DECODE(deptno,'20',sal,0)) 部门20,
SUM(DECODE(deptno,'30',sal,0)) 部门30,
SUM(DECODE(deptno,'40',sal,0)) 部门40,
SUM(DECODE(deptno,'50',sal,0)) 部门50
FROM emp
GROUP BY empno,ename;