SQL - Recursive Heirarchy Trees

Assuming a table something like this:
PERSON_ID
PARENT_ID
NAME
Start with this.
SELECT
LPAD(' ', 2*level-1) || SYS_CONNECT_BY_PATH(NAME, '\') "Path"
FROM TABLE_NAME
CONNECT BY PRIOR PERSON_ID = PARENT_ID;
Google "Connect By" for more information.

0 comments: