select * from DT_INDUSTRY t start with industrycode IN (select industrycode from SYS_COMPANY_INDUSTRY t WHERE t.compid='541572482EDA4D4A9AA6E4AFB31A3782') connect by prior INDUSTRYPCODE = industrycode SELECT SUBSTR(MAX(SYS_CONNECT_BY_PATH(NAME, '@sirc')), 6) AS NAME, SUBSTR(MAX(SYS_CONNECT_BY_PATH(ID, '@sirc')), 6) AS ID FROM SpecificFolderRelation B START WITH B.ID = P_ID CONNECT BY PRIOR B.PARENTID = B.ID;