Despite the fact that you don't want to use grouping features of you Report or Grid or anything else that shows your data, here is SQL that produces that output for proving that everything is possible in SQL . But repeatedly I suggest using grouping features in UI or Report.
with a
as(
select tbdep.id, tbdep.name , cast(cast(tbdep.id as varchar) + 'd' as varchar) as dn from tbdep
union all
select t.id, t.name,cast( cast(a.id as varchar) + cast(t.id as varchar)as varchar) as dn from tbemp t inner join a on t.did = a.id where a.dn like '%d'
)
select name from a
order by dn desc
Hope it helps.