Hierarchical Queries

Published July 26, 2025 By Sai Sree Ram Gundepudi

Hierarchical Queries

SELECT employee_id, first_name, manager_id, LEVEL
FROM employees
START WITH manager_id IS NULL
CONNECT BY PRIOR employee_id = manager_id;

LEVEL shows depth of hierarchy. Useful for org charts, bill of materials, etc.

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article