안녕하세요
쿼리 질문이 있어서 문의 드립니다.
WITH T AS
(SELECT '김철수' AS EMPNO, '201411' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL UNION ALL
SELECT '김철수' AS EMPNO, '201412' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL UNION ALL
SELECT '김철수' AS EMPNO, '201501' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL UNION ALL
SELECT '김철수' AS EMPNO, '201502' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL UNION ALL
SELECT '이영호' AS EMPNO, '201412' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL UNION ALL
SELECT '이영호' AS EMPNO, '201501' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL UNION ALL
SELECT '이영호' AS EMPNO, '201502' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL UNION ALL
SELECT '박수영' AS EMPNO, '201411' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL UNION ALL
SELECT '박수영' AS EMPNO, '201412' AS YYMM, '100' AS KOREA, '90' AS ENGLISH FROM DUAL
)
SELECT * FROM T
위와 같은 쿼리를 쓰면
|
EMPNO |
YYMM |
KOREA |
ENGLISH |
1 |
김철수 |
201411 |
100 |
90 |
2 |
김철수 |
201412 |
100 |
90 |
3 |
김철수 |
201501 |
100 |
90 |
4 |
김철수 |
201502 |
100 |
90 |
5 |
이영호 |
201412 |
100 |
90 |
6 |
이영호 |
201501 |
100 |
90 |
7 |
이영호 |
201502 |
100 |
90 |
8 |
박수영 |
201411 |
100 |
90 |
9 |
박수영 |
201412 |
100 |
90 |
이렇게 나오는데요..
이런 쿼리를
EMPNO |
YYMM |
KOREA |
ENGLISH |
YYMM |
KOREA |
ENGLISH |
YYMM |
KOREA |
ENGLISH |
YYMM |
KOREA |
ENGLISH |
김철수 |
201411 |
100 |
90 |
201412 |
100 |
90 |
201501 |
100 |
90 |
201502 |
100 |
90 |
이영호 |
|
|
|
201412 |
100 |
90 |
201501 |
100 |
90 |
201502 |
100 |
90 |
박수영 |
201411 |
100 |
90 |
201412 |
100 |
90 |
|
|
|
|
|
|
이렇게 나오도록 할 수 있는게 가능 한건가요?
쿼리 한방으로 뽑고 싶은데 안된다며 프로그램을 짜야 될거 같아서 질문 드립니다.
|