select count(decode(to_char(hiredate,'mm'), '01', 1)) "1월",
count(decode(to_char(hiredate,'mm'), '02', 1)) "2월",
count(decode(to_char(hiredate,'mm'), '03', 1)) "3월",
count(decode(to_char(hiredate,'mm'), '04', 1)) "4월",
count(decode(to_char(hiredate,'mm'), '05', 1)) "5월",
count(decode(to_char(hiredate,'mm'), '06', 1)) "6월",
count(decode(to_char(hiredate,'mm'), '07', 1)) "7월",
count(decode(to_char(hiredate,'mm'), '08', 1)) "8월",
count(decode(to_char(hiredate,'mm'), '09', 1)) "9월",
count(decode(to_char(hiredate,'mm'), '10', 1)) "10월",
count(decode(to_char(hiredate,'mm'), '11', 1)) "11월",
count(decode(to_char(hiredate,'mm'), '12', 1)) "12월",
count(*) "전체"
from emp
where to_char(hiredate,'mm') >= '01' and
to_char(hiredate,'mm') <= '12';
DECODE 함수 사용 방법
decode(검색컬럼, 조건1, 결과값1,..., 기본값)
[출처] 오라클 Decode 예제|작성자 흑향