장비 | 배출일자 | 배출량 |
1111 | 20130105 | 100 |
1111 | 20130304 | 200 |
2222 | 20130601 | 300 |
3333 | 20130701 | 400 |
3333 | 20130708 | 500 |
4444 | 20130630 | 600 |
1111 | 20130321 | 700 |
2222 | 20130308 | 800 |
장비 | 1월 | 2월 | 3월 | 4월 | 5월 | 6월 | 7월 | 8월 | 9월 | 10월 | 11월 | 12월 |
1111 | 1 | - | 2 | - | - | - | - | - | - | - | - | - |
2222 | - | - | 1 | - | - | 1 | - | - | - | - | - | - |
3333 | - | - | - | - | - | - | 2 | - | - | - | - | - |
4444 | - | - | - | - | - | 1 | - | - | - | - | - | - |
WITH T ( EQ , DT , VAL ) AS ( SELECT '1111' ,'20130105' ,'100' FROM DUAL UNION ALL SELECT '1111' ,'20130304' ,'200' FROM DUAL UNION ALL SELECT '2222' ,'20130601' ,'300' FROM DUAL UNION ALL SELECT '3333' ,'20130701' ,'400' FROM DUAL UNION ALL SELECT '3333' ,'20130708' ,'500' FROM DUAL UNION ALL SELECT '4444' ,'20130630' ,'600' FROM DUAL UNION ALL SELECT '1111' ,'20130321' ,'700' FROM DUAL UNION ALL SELECT '2222' ,'20130308' ,'800' FROM DUAL ) SELECT EQ ,COUNT(DECODE(MM,'01',1)) "1월" ,COUNT(DECODE(MM,'02',1)) "2월" ,COUNT(DECODE(MM,'03',1)) "3월" ,COUNT(DECODE(MM,'04',1)) "4월" ,COUNT(DECODE(MM,'05',1)) "5월" ,COUNT(DECODE(MM,'06',1)) "6월" ,COUNT(DECODE(MM,'07',1)) "7월" ,COUNT(DECODE(MM,'08',1)) "8월" ,COUNT(DECODE(MM,'09',1)) "9월" ,COUNT(DECODE(MM,'10',1)) "10월" ,COUNT(DECODE(MM,'11',1)) "11월" ,COUNT(DECODE(MM,'12',1)) "12월" FROM (SELECT EQ , SUBSTR(DT,5,2) MM , VAL FROM T WHERE DT LIKE '2013%' )a GROUP BY EQ ORDER BY EQ