My account structure is tree based:
| code | Title |
|---|---|
| 1 | abc |
| 1-1 | kkk |
| 1-1-1 | dfgf |
| 1-1-1-1 | dfsd |
| 1-1-1-1-1-1 | sdfsd |
| 1-1-1-1-1-1-1 | sccdfsd |
I have 5000 records in this tree need result level wise
grand-fmother , father, child........
level1-tilte,level2-tilte,leve3-tilte,level4-tilte,level5-tilte,leve6-tilte,level7-tilte,level8-tilte,level9-tilte
How to get all parent title names level-wise in separate column?
You can detect number of elements in CODE column that defines levels of parenthood and use it in PIVOT to get the titles:
If you want to use connect by you can just change the inner sql like below:
The result is the same as above.