1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | SELECT area.area_code AS code , NVL(area. name , '전국' ) AS name , COUNT (stb.stb_code) AS stb_tot FROM tbl_area area , ( SELECT c.area_code , c.stb_code FROM tbl_account a , tbl_account b , tbl_stb c WHERE a.type = '03' AND a.acc_no = b.parent_acc_no AND b.acc_no = c.acc_no ) stb WHERE area.parent_code = 0 AND area.area_code = stb.area_code(+) GROUP BY ROLLUP ((area.area_code, area. name )) ORDER BY GROUPING (area.area_code), stb_tot DESC ; |