Opdater
Når du har set din opdatering, skal du bare slippe START MED.
Afslut opdatering
CONNECT_BY_ROOT er det, du leder efter
Denne erklæring
SELECT distinct RootBoss, Person FROM (
with employee as
(
Select 1 person , null boss from Dual
UNION Select 2 , 1 from dual
UNION Select 3 , 2 from dual
)
SELECT CONNECT_BY_ROOT boss RootBoss, person
FROM employee connect_by
connect by prior person = boss
ORDER BY person
) t
WHERE ROOTBOSS is not null
ORDER BY
RootBoss, Person
Udgange
ROOTBOSS PERSON
---------------------- ----------------------
1 2
1 3
2 3
Det er ret nemt at tilføje SUMMER og GRUPPER