SELECT SUM(DECODE(DEPTNO, 10, SAL)) AS '10',
SUM(DECODE(DEPTNO, 20, SAL)) AS '20',
SUM(DECODE(DEPTNO, 30, SAL)) AS '30',
FROM EMP;
10 | 20 | 30
8750 | 10875 | 9400
SELECT DEPTNO, DECODE(DEPTNO, 10, SAL) AS '10'
FROM EMP;
SELECT SUM(DECODE(DEPTNO, 10, SAL)) AS '10'
FROM EMP;
10
8750
SELECT SUM(DECODE(JOB, 'ANALYST', SAL)) AS 'ANALYST',
SUM(DECODE(JOB, 'CLERK', SAL)) AS 'CLERK',
SUM(DECODE(JOB, 'MANAGER', SAL)) AS 'MANAGER',
SUM(DECODE(JOB, 'SALESMAN', SAL)) AS 'SALESMAN',
FROM EMP;
ANALYST | CLERK | MANAGER | SALESMAN
6000 | 4150 | 8275 | 5600
SELECT DEPTNO, SUM(DECODE(JOB, 'ANALYST', SAL)) AS 'ANALYST',
SUM(DECODE(JOB, 'CLERK', SAL)) AS 'CLERK',
SUM(DECODE(JOB, 'MANAGER', SAL)) AS 'MANAGER',
SUM(DECODE(JOB, 'SALESMAN', SAL)) AS 'SALESMAN',
FROM EMP
GROUP BY DEPTNO;
DEPTNO | ANALYST | CLERK | MANAGER | SALESMAN
30 | | 950 | 2850 | 5600
10 | | 1300 | 2450 |
20 | 6000 | 1900 | 2975 |