10G 에선 CONNECT_BY_ROOT 가 가능합니다.
9i 라면 SYS_CONNECT_BY_PATH 를 응용하시면 될듯.
SELECT NVL2(a.root_dept_cd,MIN(DECODE(a.lv,1,a.root_dept_nm)),'계') AS dept_nm
, SUM(b.cnt) AS "계"
, SUM(CASE WHEN b.work_grade_cd = '101' THEN b.cnt END) AS pre1
, SUM(CASE WHEN b.work_grade_cd = '102' THEN b.cnt END) AS pre2
-- 중략 --
, SUM(CASE WHEN b.work_grade_cd = '130' THEN b.cnt END) AS pre23
, SUM(CASE WHEN b.work_grade_cd = '131' THEN b.cnt END) AS pre24
FROM (SELECT LEVEL lv
, dept_cd
, dept_nm
, SUBSTR(SYS_CONNECT_BY_PATH(dept_cd,'-'),2,7) root_dept_cd
FROM a_deptcd
START WITH pdept_cd = '1000000' AND use_yn = 'Y'
CONNECT BY PRIOR dept_cd = pdept_cd
) a
, (SELECT b.dept_cd
, b.work_grade_cd
, COUNT(*) cnt
FROM a_employee b
, st_codevalue c
WHERE b.retire_dt IS NULL
AND b.work_grade_cd = c.code_value
AND c.code_cd = 'C116'
AND c.use_yn = 'Y'
GROUP BY b.dept_cd, b.work_grade_cd
) b
WHERE a.deptcd = b.dept_cd(+)
GROUP BY ROLLUP(a.root_dept_cd)
ORDER BY GROUPING(a.root_dept_cd) DESC, a.root_dept_cd