1 2 3 4 5 6 7 8 9 10 11 12 13 | WITH t AS ( SELECT '서울' sido, '마포구' gugun, 1 cnt FROM dual UNION ALL SELECT '서울' , '관악구' , 2 FROM dual UNION ALL SELECT '경기' , '수원시' , 2 FROM dual UNION ALL SELECT '경기' , '남양주시' , 9 FROM dual ) SELECT NVL2(sido, sido || '(' || NVL(gugun, '전체' ) || ')' , '계' ) loc , SUM (cnt) cnt FROM t GROUP BY ROLLUP (sido, gugun) ORDER BY sido, gugun NULLS FIRST ; |