WITH temp (departure , arrival, niveau ) as (
SELECT departure, arrival, 1 from flights where departure = 'Chicago'
UNION ALL
SELECT f.departure, f.arrival, t.niveau + 1)
from temp T join flights F on t.arrival = f.departure
)
SEARCH DEPTH FIRST BY arrival SET tri
Select * From Temp ORDER BY tri
les requêtes hiérarchiques proposent en plus un tri, pour les lignes
"soeurs" (siblings, ayant les mêmes parents).
SELECT CONNECT_BY_ROOT departure AS origin, departure, arrival,
LEVEL niveau, price prix
FROM flights
START WITH departure = 'New York'
CONNECT BY PRIOR arrival = departure
ORDER SIBLINGS BY price ASC
classe, pour les trajets ayant la même origine, par prix croissant
|