(
select distinct o.orgid,o.parentorgid from baf_org_organization o where o.orgid='11' and o.isvalid='Y'
union all
select distinct o.orgid,o.parentorgid from baf_org_organization o
inner join temp b on o.parentorgid = b.orgid
)
select orgid from temp
Oracle