1) 자료(raw데이터) 가 아래와 같이 있을 때
2) 아래와 같이 통계 자료 추출이 가능할까요?
WITH t AS ( SELECT 'A' gb1, 'PP1' gb2 FROM dual UNION ALL SELECT 'A', 'PP2' FROM dual UNION ALL SELECT 'A', 'PP2' FROM dual UNION ALL SELECT 'B', 'PP1' FROM dual UNION ALL SELECT 'B', 'PP2' FROM dual UNION ALL SELECT 'B', 'PP2' FROM dual UNION ALL SELECT 'B', 'PP2' FROM dual UNION ALL SELECT 'C', 'PP2' FROM dual ) SELECT NVL(b.gb1, '계') gb1 , a.gb2 , COUNT(b.gb2) cnt FROM (SELECT DISTINCT gb2 FROM t) a LEFT OUTER JOIN t b PARTITION BY (b.gb1) ON a.gb2 = b.gb2 GROUP BY ROLLUP((b.gb1, a.gb2)) ORDER BY GROUPING(b.gb1) DESC, b.gb1, a.gb2 ;