Ordering the siblings v16
You can order the result set so the siblings appear in ascending or descending order by selected column values using the ORDER SIBLINGS BY
clause. This is a special case of the ORDER BY
clause that you can use only with hierarchical queries.
You can further modify the previous query by adding 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 don't satisfy the WHERE
clause were eliminated from the output.