with DEPT1 as(
select DEPARTID ,PARENTID from DEPARTMENT
),
DEPT2 as(
select * from DEPT1 where DEPARTID=8
union all
select DEPT1.* from DEPT2 inner join DEPT1
on DEPT2.PARENTID=DEPT1.DEPARTID
)
select * from DEPT2
with DEPT1 as(
select DEPARTID ,PARENTID from DEPARTMENT
),
DEPT2 as(
select * from DEPT1 where DEPARTID=8
union all
select DEPT1.* from DEPT2 inner join DEPT1
on DEPT2.PARENTID=DEPT1.DEPARTID
)
select * from DEPT2