I have a requirement to build a table from a hierarchical table. Table structure as below: emp_hier table: emp_id supervisorId 100 null 1 100 2 1 3 2 New table: I have to write a select query on the emp_heir table and the selected data should look like this: sel_emp_id rel_emp_id relation depth_lvl 100 100 self 0 100 1 My
Tag: hierarchical-query
Oracle SQL hierarchical query from bottom to top
I have a table where I want to go from bottom to top using hierarchical queries. The problem is that I need the get the value of one column from root (top) using CONNECT_BY_ROOT, but since I reverse the way the hierarchical query works (reverse the prior in connect by and the start with), this function (CONNECT_BY_ROOT) consider my ‘start
How to get the root record in Oracle database
Starting from the generic node (or leaf) how to get the root node? How to get the root msg_id? Answer You were on the right path, but you are missing two essential ingredients. First, to indicate the starting point, you need to use the start with clause. Obviously, it will be something like start with id = <input value>. You