다음과 같은 계층구조가 있는데요.
CODE |
CHILD_CODE |
GRADE |
A |
A1 |
1 |
A |
A2 |
1 |
A |
A3 |
3 |
A |
A4 |
6 |
A1 |
A3 |
3 |
A1 |
A4 |
6 |
A4 |
B1 |
1 |
A4 |
B2 |
6 |
B2 |
C1 |
1 |
B2 |
C2 |
2 |
C1 |
D1 |
5 |
C1 |
D2 |
5 |
이 구조에서 GRADE가 6을 연결한 데이타만 조회하고 싶습니다.
다음과 조회하면 되는데 방법 좀 알려주세요...^^
CODE |
CHILD_CODE |
GRADE |
A |
A1 |
1 |
A |
A2 |
1 |
A |
A3 |
3 |
A |
A4 |
6 |
A4 |
B1 |
1 |
A4 |
B2 |
6 |
B2 |
C1 |
1 |
B2 |
C2 |
2 |
감사합니다.
SELECT 'A' CODE, 'A1' CHILD_CODE, '1' GRADE
FROM DUAL
UNION ALL
SELECT 'A' CODE, 'A2' CHILD_CODE, '1' GRADE
FROM DUAL
UNION ALL
SELECT 'A' CODE, 'A3' CHILD_CODE, '3' GRADE
FROM DUAL
UNION ALL
SELECT 'A' CODE, 'A4' CHILD_CODE, '6' GRADE
FROM DUAL
UNION ALL
SELECT 'A1' CODE, 'A3' CHILD_CODE, '3' GRADE
FROM DUAL
UNION ALL
SELECT 'A1' CODE, 'A4' CHILD_CODE, '6' GRADE
FROM DUAL
UNION ALL
SELECT 'A4' CODE, 'B1' CHILD_CODE, '1' GRADE
FROM DUAL
UNION ALL
SELECT 'A4' CODE, 'B2' CHILD_CODE, '6' GRADE
FROM DUAL
UNION ALL
SELECT 'B2' CODE, 'C1' CHILD_CODE, '1' GRADE
FROM DUAL
UNION ALL
SELECT 'B2' CODE, 'C2' CHILD_CODE, '2' GRADE
FROM DUAL
UNION ALL
SELECT 'C1' CODE, 'D1' CHILD_CODE, '5' GRADE
FROM DUAL
UNION ALL
SELECT 'C1' CODE, 'D2' CHILD_CODE, '5' GRADE
FROM DUAL |