I have a tree structure that I am trying to recuperate via a statement in sql developer for an output display. The tree is of four levels, while level four represents the documents attached on level three.
this is my query:
select CASE WHEN level=4 THEN node.name END as Level_One,
CASE WHEN level=5 THEN node.name END as Level_Two,
CASE WHEN level=6 THEN node.name END as Level_Three,
doc.lib_doc as LABEL
from treenode node
left join rules ru on ru.datatype = node.octype
left join prs pr on pr.key = ru.datatype
left join file fl on fl.code = pr.prcode
left join ref_doc refd on refd.mn_doc = fl.code
left join ref_document doc on refd.id_doc = doc.id_doc
connect by prior node.key = node.father_id
start with node.father_id =-1;
The problem is that I am displaying the same level three node.name for each doc.lib_doc attached and thus getting the same value duplicated as much as there are doc.lib_doc as below:
Level_One | Level_Two | Level_Three | LABEL |
---|---|---|---|
1 - resp | 1 - Right | 1 - Element | abc |
1 - Element | test | ||
1 - Element | 125 | ||
1 - Element | test1 | ||
1 - Element | file | ||
2 - ElementA | fileXYZ | ||
2 - ElementA | fileABC | ||
2 - respa | 1 - Access | 1 - right | abc |
While I am without success trying to get the display below without duplication in tree levels:
Level_One | Level_Two | Level_Three | LABEL |
---|---|---|---|
1 - resp | 1 - Right | 1 - Element | abc |
test | |||
125 | |||
test1 | |||
file | |||
2 - ElementA | fileXYZ | ||
fileABC | |||
2 - respa | 1 - Access | 1 - right | abc |
Any suggestions on how to achieve this behavior in the statement?