Node level v14
LEVEL
is a pseudo-column that you can use wherever a column can appear in the SELECT
command. For each row in the result set, LEVEL
returns a non-zero integer value designating the depth in the hierarchy of the node represented by this row. The LEVEL
for root nodes is 1. The LEVEL
for direct children of root nodes is 2, and so on.
The following query is a modification of the previous query with the addition of the LEVEL
pseudo-column. In addition, using the LEVEL
value, the employee names are indented to further emphasize the depth in the hierarchy of each row.
The output from this query is:
Nodes that share a common parent and are at the same level are called siblings. For example, in the above output, employees ALLEN
, WARD
, MARTIN
, TURNER
, and JAMES
are siblings since they are all at level three with parent BLAKE
. JONES
, BLAKE
, and CLARK
are siblings since they are at level two and KING
is their common parent.