Level Assignment Help

Assignment Help: >> Pseudo-columns - Level

Level

For each row returned through a hierarchical query and the LEVEL pseudocolumn returns 1 for the root node, 2 for a child node and many more. A root node is the highest node within an inverted tree. The child node is any non-root node. The parent node is any row which has children. Leaf node is any row without children. The subsequent diagram describes the nodes of an inverted tree with their LEVEL values.

 

                           1116_Level.png

To describe the hierarchical relationship in a query by use START WITH clause and CONNECT BY clause. The following example describes this:

SELECT LPAD(ENAME,10*LEVEL) FROM EMP
START WITH MGR IS NULL
CONNECT BY MGR=PRIOR EMPNO;
The output of the above query will be:
LPAD(ENAME,10*LEVEL)

 

                              1670_Level 1.png

 

Because King is the top most employees so the execution will begin with the start with clause and the next connection will be based on CONNECT BY clause.
In this instance example CONNECT BY MGR=PRIOR EMPNO compares the last selected empno (first King’s employee no) with the matching manager No’s in Manager Column and displays those records under KING and so on.

 

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd