WITH TMP AS (
SELECT '2003' YY, '02' P_CD, '03' GUBUN, 'QWE' S_CD FROM DUAL
UNION ALL
SELECT '2003', '02', '03', 'ERW' FROM DUAL
UNION ALL
SELECT '2003', '02', '03', 'RTY' FROM DUAL
UNION ALL
SELECT '2003', '02', '03', 'CXV' FROM DUAL
UNION ALL
SELECT '2003', '02', '01', 'VBN' FROM DUAL
UNION ALL
SELECT '2003', '02', '02', 'GYK' FROM DUAL
UNION ALL
SELECT '2003', '02', '03', 'LEK' FROM DUAL
)
SELECT A.YY,A.P_CD
,A.S_CD
, B.CNT
FROM TMP A
INNER JOIN (SELECT YY,P_CD,GUBUN, COUNT(*) OVER() AS CNT
FROM TMP A
GROUP BY YY, P_CD, GUBUN) B ON A.YY = B.YY AND A.P_CD = B.P_CD
GROUP BY A.YY, A.P_CD, A.S_CD, B.CNT
위처럼 그룹에 속해있지 않은 칼럼(GUBUN)의 그룹핑갯수를 구하고 싶은데
조인을 안하고 구할 수 있는 방법이 없을까요?