-
How to get all the parents of a given node from a tree in single row?
HI,
I have a requirement to get the all the parent nodes till the root, of all the leaf nodes in a Tree structure in a single row instead of multiple rows.
Normally we can get the tree structure as follows for a leaf level node_id : 1023.
select node_id,node_name,node_level,parent_node_id
from tree
start with node_id=1023
connect by prior parent_node_id=node_id
This query returns all the parents of the leaf nodes, but in multiple rows as follows
1023, node_district, 4, 1022
1022, node_region, 3, 1021
1021, node_state, 2, 1020
1020, node_company, 1, 0
but my requirement is to get the node_names as follows in a single row.
node_company, node_state, node_region, node_district
How should I achieve this with a SQL query?
Thank you,
Srinivas Medukonduru
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|