Ordering the Siblings v12
The result set can be ordered so the siblings appear in ascending or descending order by selected column value(s) using the ORDER SIBLINGS BY
clause. This is a special case of the ORDER BY
clause that can be used only with hierarchical queries.
The previous query is further modified with the addition of ORDER SIBLINGS BY
ename ASC
.
The output from the prior query is now modified so the siblings appear in ascending order by name. Siblings BLAKE, CLARK
, and JONES
are now alphabetically arranged under KING
. Siblings ALLEN, JAMES, MARTIN, TURNER
, and WARD
are alphabetically arranged under BLAKE
, and so on.
This final example adds the WHERE
clause and starts with three root nodes. After the node tree is constructed, the WHERE
clause filters out rows in the tree to form the result set.
The output from the query shows three root nodes (level one) - BLAKE, CLARK
, and JONES
. In addition, rows that do not satisfy the WHERE
clause have been eliminated from the output.