Reputation: 1138
Data:
ID PARENT_ID
1 [null]
2 1
3 1
4 2
Desired result:
ID CHILD_AT_ANY_LEVEL
1 2
1 3
1 4
2 4
I've tried SYS_CONNECT_BY_PATH, but I don't understand how to convert it result into "inline view" which I can use for JOIN with main table.
Upvotes: 0
Views: 42
Reputation: 553
select connect_by_root(id) id, id child_at_any_level
from table
where level <> 1
connect by prior id = parent_id;
Upvotes: 1