사원번호 | 사원명 | 업무유형1 | 업무유형2 | 처리상태 | 접수일시 | 처리일시 |
1 | 홍길동 | A | A1 | 신청 | 2013-01-05 13:00:35 | |
1 | 홍길동 | A | A1 | 신청 | 2013-01-05 13:10:25 | |
1 | 홍길동 | A | A1 | 취소 | 2013-01-05 13:00:05 | |
1 | 홍길동 | A | A2 | 완료 | 2013-01-05 13:00:09 | 2013-01-05 13:30:45 |
1 | 홍길동 | A | A2 | 완료 | 2013-01-05 13:15:10 | 2013-01-05 14:00:31 |
1 | 홍길동 | A | A2 | 완료 | 2013-01-06 13:00:24 | 2013-01-07 09:57:27 |
2 | 김길동 | A | A1 | 신청 | 2013-01-05 13:00:56 | |
2 | 김길동 | A | A1 | 신청 | 2013-01-05 13:00:34 | |
2 | 김길동 | A | A1 | 취소 | 2013-01-05 13:00:32 | |
2 | 김길동 | A | A2 | 완료 | 2013-02-01 13:00:55 | 2013-02-01 13:05:57 |
2 | 김길동 | A | A2 | 완료 | 2013-03-05 13:00:23 | 2013-03-07 14:30:00 |
2 | 김길동 | A | A2 | 완료 | 2013-01-06 13:00:00 | 2013-01-06 13:05:27 |
2 | 김길동 | B | B1 | 완료 | 2013-01-07 13:00:10 | 2013-01-07 15:56:14 |
2 | 김길동 | B | B1 | 신청 | 2013-01-05 13:00:07 | |
2 | 김길동 | B | B1 | 완료 | 2013-01-10 13:00:39 | 2013-01-10 14:00:12 |
2 | 김길동 | B | B1 | 취소 | 2013-01-05 13:00:45 | |
2 | 김길동 | B | B1 | 취소 | 2013-01-05 13:00:20 | |
2 | 김길동 | B | B2 | 완료 | 2013-01-11 13:00:31 | 2013-01-11 13:13:57 |
사원번호 | 사원명 | 업무유형1 | 업무유형2 | 처리상태 | 평균처리시간 | ||
신청 | 취소 | 완료 | |||||
1 | 홍길동 | A | A1 | 2 | 1 | 0 | |
1 | 홍길동 | A | A2 | 0 | 0 | 3 | |
2 | 김길동 | A | A1 | 2 | 1 | 0 | |
2 | 김길동 | A | A2 | 0 | 0 | 3 | |
2 | 김길동 | B | B1 | 1 | 2 | 2 | |
2 | 김길동 | B | B2 | 0 | 0 | 1 |
WITH T ( 사원번호 ,사원명 ,업무유형1 ,업무유형2 ,처리상태,접수일시 ,처리일시 ) AS ( SELECT '1','홍길동','A','A1','신청','2013-01-05 13:00:35','' FROM DUAL UNION ALL SELECT '1','홍길동','A','A1','신청','2013-01-05 13:10:25','' FROM DUAL UNION ALL SELECT '1','홍길동','A','A1','취소','2013-01-05 13:00:05','' FROM DUAL UNION ALL SELECT '1','홍길동','A','A2','완료','2013-01-05 13:00:09','2013-01-05 13:30:45' FROM DUAL UNION ALL SELECT '1','홍길동','A','A2','완료','2013-01-05 13:15:10','2013-01-05 14:00:31' FROM DUAL UNION ALL SELECT '1','홍길동','A','A2','완료','2013-01-06 13:00:24','2013-01-07 09:57:27' FROM DUAL UNION ALL SELECT '2','김길동','A','A1','신청','2013-01-05 13:00:56','' FROM DUAL UNION ALL SELECT '2','김길동','A','A1','신청','2013-01-05 13:00:34','' FROM DUAL UNION ALL SELECT '2','김길동','A','A1','취소','2013-01-05 13:00:32','' FROM DUAL UNION ALL SELECT '2','김길동','A','A2','완료','2013-02-01 13:00:55','2013-02-01 13:05:57' FROM DUAL UNION ALL SELECT '2','김길동','A','A2','완료','2013-03-05 13:00:23','2013-03-07 14:30:00' FROM DUAL UNION ALL SELECT '2','김길동','A','A2','완료','2013-01-06 13:00:00','2013-01-06 13:05:27' FROM DUAL UNION ALL SELECT '2','김길동','B','B1','완료','2013-01-07 13:00:10','2013-01-07 15:56:14' FROM DUAL UNION ALL SELECT '2','김길동','B','B1','신청','2013-01-05 13:00:07','' FROM DUAL UNION ALL SELECT '2','김길동','B','B1','완료','2013-01-10 13:00:39','2013-01-10 14:00:12' FROM DUAL UNION ALL SELECT '2','김길동','B','B1','취소','2013-01-05 13:00:45','' FROM DUAL UNION ALL SELECT '2','김길동','B','B1','취소','2013-01-05 13:00:20','' FROM DUAL UNION ALL SELECT '2','김길동','B','B2','완료','2012-01-11 13:00:31','2013-01-11 13:13:57' FROM DUAL ) SELECT a.* , TRUNC(DD*24)||':'||TO_CHAR( TO_DATE('20000101000000' ,'YYYYMMDDHH24MISS') + DD ,'MI:SS' ) FROM (SELECT 사원번호 , 사원명 , 업무유형1 , 업무유형2 , COUNT(DECODE(처리상태,'신청',1)) 신청 , COUNT(DECODE(처리상태,'취소',1)) 취소 , COUNT(DECODE(처리상태,'완료',1)) 완료 , AVG(DECODE(처리상태,'완료',TO_DATE(처리일시,'YYYY-MM-DD HH24:MI:SS') - TO_DATE(접수일시,'YYYY-MM-DD HH24:MI:SS'))) DD FROM T GROUP BY 사원번호 ,사원명 ,업무유형1 ,업무유형2 ) a ORDER BY 1 , 3 , 4
WITH t AS ( SELECT empno, ename, gb1, gb2, st , TO_DATE(sdt, 'yyyy-mm-dd hh24:mi:ss') sdt , TO_DATE(edt, 'yyyy-mm-dd hh24:mi:ss') edt FROM ( SELECT 1 empno, '홍길동' ename, 'A' gb1, 'A1' gb2, '신청' st, '2013-01-05 13:00:35' sdt, '' edt FROM dual UNION ALL SELECT 1, '홍길동', 'A', 'A1', '신청', '2013-01-05 13:10:25', '' FROM dual UNION ALL SELECT 1, '홍길동', 'A', 'A1', '취소', '2013-01-05 13:00:05', '' FROM dual UNION ALL SELECT 1, '홍길동', 'A', 'A2', '완료', '2013-01-05 13:00:09', '2013-01-05 13:30:45' FROM dual UNION ALL SELECT 1, '홍길동', 'A', 'A2', '완료', '2013-01-05 13:15:10', '2013-01-05 14:00:31' FROM dual UNION ALL SELECT 1, '홍길동', 'A', 'A2', '완료', '2013-01-06 13:00:24', '2013-01-07 09:57:27' FROM dual UNION ALL SELECT 2, '김길동', 'A', 'A1', '신청', '2013-01-05 13:00:56', '' FROM dual UNION ALL SELECT 2, '김길동', 'A', 'A1', '신청', '2013-01-05 13:00:34', '' FROM dual UNION ALL SELECT 2, '김길동', 'A', 'A1', '취소', '2013-01-05 13:00:32', '' FROM dual UNION ALL SELECT 2, '김길동', 'A', 'A2', '완료', '2013-02-01 13:00:55', '2013-02-01 13:05:57' FROM dual UNION ALL SELECT 2, '김길동', 'A', 'A2', '완료', '2013-03-05 13:00:23', '2013-03-07 14:30:00' FROM dual UNION ALL SELECT 2, '김길동', 'A', 'A2', '완료', '2013-01-06 13:00:00', '2013-01-06 13:05:27' FROM dual UNION ALL SELECT 2, '김길동', 'B', 'B1', '완료', '2013-01-07 13:00:10', '2013-01-07 15:56:14' FROM dual UNION ALL SELECT 2, '김길동', 'B', 'B1', '신청', '2013-01-05 13:00:07', '' FROM dual UNION ALL SELECT 2, '김길동', 'B', 'B1', '완료', '2013-01-10 13:00:39', '2013-01-10 14:00:12' FROM dual UNION ALL SELECT 2, '김길동', 'B', 'B1', '취소', '2013-01-05 13:00:45', '' FROM dual UNION ALL SELECT 2, '김길동', 'B', 'B1', '취소', '2013-01-05 13:00:20', '' FROM dual UNION ALL SELECT 2, '김길동', 'B', 'B2', '완료', '2013-01-11 13:00:31', '2013-01-11 13:13:57' FROM dual ) ) SELECT empno, ename, gb1, gb2 , cnt1, cnt2, cnt3 , NVL2(sec, FLOOR(sec / (24*60*60)) || ':', '') || TO_CHAR(TO_DATE(MOD(sec, 24*60*60), 'sssss'), 'hh24:mi:ss') tm FROM (SELECT empno, ename, gb1, gb2 , COUNT(DECODE(st, '신청', 1)) cnt1 , COUNT(DECODE(st, '취소', 1)) cnt2 , COUNT(DECODE(st, '완료', 1)) cnt3 , ROUND(AVG(edt - sdt)*24*60*60) sec FROM t GROUP BY empno, ename, gb1, gb2 ) ORDER BY empno, gb1, gb2 ;