I have a dataset where first column is employee code and second column is manager code. I am trying to output an extract where reporting structure is clearly visible. How can I do that? I would appreciate any clues. Below are sample dataset and expected output.
CodePudding user response:
You simply need a CONNECT BY clause and LPAD function combination -
SELECT LPAD('*', LEVEL - 1, '*') || col_org Col_hierarchy_org
FROM DATA D
START WITH col_org_predecessor IS NULL
CONNECT BY PRIOR col_org = col_org_predecessor;