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 ;