select sum(decode(deptno,10,sal)) as "10", sum(decode(deptno,20,sal)) as "20", sum(decode(deptno,30,sal)) as "30" from emp; --decode의 else에 0보다 null이 낫다.