WITH TEMP AS (
SELECT 1 NUM, 'AAA' P_CTG_CODE, 'AAA-111' CTG_DESC FROM DUAL
UNION ALL SELECT 2, 'AAA', 'AAA-111' FROM DUAL
UNION ALL SELECT 3, 'AAA', 'AAA-111' FROM DUAL
UNION ALL SELECT 4, 'BBB', 'BBB-111' FROM DUAL
UNION ALL SELECT 5, 'CCC', 'CCC-111' FROM DUAL
UNION ALL SELECT 6, 'CCC', 'CCC-111' FROM DUAL
UNION ALL SELECT 7, 'AAA', 'AAA-111' FROM DUAL
UNION ALL SELECT 8, 'AAA', 'AAA-111' FROM DUAL
UNION ALL SELECT 9, 'CCC', 'CCC-111' FROM DUAL
UNION ALL SELECT 10, 'CCC', 'CCC-111' FROM DUAL
UNION ALL SELECT 11, 'BBB', 'BBB-111' FROM DUAL
UNION ALL SELECT 12, 'BBB', 'BBB-111' FROM DUAL
)
SELECT
A.*
FROM TEMP A
다음과 같은 데이터에서 아래와 같은 결과를 가져오고 싶습니다.
도와주시면 감사하겠습니다.
NUM P_CTG_CODE CTG_DESC 그룹핑 기대값
1 AAA AAA-111===================>1
2 AAA AAA-111===================>1
3 AAA AAA-111===================>1
4 BBB BBB-111===================>2
5 CCC CCC-111===================>3
6 CCC CCC-111===================>3
7 AAA AAA-111===================>4
8 AAA AAA-111===================>4
9 CCC CCC-111===================>5
10 CCC CCC-111===================>5
11 BBB BBB-111===================>6
12 BBB BBB-111===================>6
|