find the query below :
select ts.ts_test_id, TS.TS_NAME, cp.al_path from td.test ts inner join ( select al.al_item_id, case when al1.al_description is null then '' else al1.al_description end + case when al2.al_description is null then '' else '\' + al2.al_description end + case when al3.al_description is null then '' else '\' + al3.al_description end + case when al4.al_description is null then '' else '\' + al4.al_description end + case when al5.al_description is null then '' else '\' + al5.al_description end + case when al6.al_description is null then '' else '\' + al6.al_description end + case when al7.al_description is null then '' else '\' + al7.al_description end + case when al8.al_description is null then '' else '\' + al8.al_description end + case when al9.al_description is null then '' else '\' + al9.al_description end as al_path from td.all_lists al left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 6) al1 on len(al.al_absolute_path) >= 6 and substring(al.al_absolute_path,1,6) = al1.al_absolute_path left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 9) al2 on len(al.al_absolute_path) >= 9 and substring(al.al_absolute_path,1,9) = al2.al_absolute_path left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 12) al3 on len(al.al_absolute_path) >= 12 and substring(al.al_absolute_path,1,12) = al3.al_absolute_path left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 15) al4 on len(al.al_absolute_path) >= 15 and substring(al.al_absolute_path,1,15) = al4.al_absolute_path left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 18) al5 on len(al.al_absolute_path) >= 15 and substring(al.al_absolute_path,1,18) = al5.al_absolute_path left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 21) al6 on len(al.al_absolute_path) >= 15 and substring(al.al_absolute_path,1,21) = al6.al_absolute_path left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 24) al7 on len(al.al_absolute_path) >= 15 and substring(al.al_absolute_path,1,24) = al7.al_absolute_path left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 27) al8 on len(al.al_absolute_path) >= 15 and substring(al.al_absolute_path,1,27) = al8.al_absolute_path left outer join (select al_absolute_path, al_description from td.all_lists where len(al_absolute_path) = 30) al9 on len(al.al_absolute_path) >= 15 and substring(al.al_absolute_path,1,30) = al9.al_absolute_path ) cp on ts.ts_subject = cp.al_item_id