Oracle hierarchical query join to selection of all decendants -


i trying retrieve list of each descendant each item. not sure making sense, try , explain.

example data:

id | pid -------- 1  | 0 2  | 1 3  | 1 4  | 1 5  | 2 6  | 2 7  | 5 8  | 3 

etc...

the desired results are:

id | decendant -------------- 1  | 1 1  | 2 1  | 3 1  | 4 ... 2  | 2 2  | 5 2  | 6 2  | 7 3  | 3 3  | 8 

etc...

this being achieved using cursor move through data , inserting each descendant table , selecting them.

i wondering if there better way these, there must way right query bring desired results.

if 1 has ideas, or has figured out before appreciated. ordering not important, nor 1 - 1, 2 -2 reference. cool have it, not crucial.

select connect_by_root(id) id, id decendant table1 connect prior id = pid order 1, 2 

fiddle


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -