oracle - Connect by clause to get the top of hierarchy -
i facing issue while using connect by
clause in oracle finding hierarchical data. let me give example: parent part has child part b , b has child part c. when using connect by
clause able 3 levels want top level, i.e. a.
oracle has level
pseudocolumn can use:
select mytable.id, mytable.parentid mytable level = 1 connect prior mytable.id = mytable.parentid
to find top-level (root) value level, precede column name connect_by_root
operator:
select mytable.id, mytable.parentid, connect_by_root mytable.id "top level id" mytable connect prior mytable.id = mytable.parentid
Comments
Post a Comment