|
|
Archives of the TeradataForum
Message Posted: Mon, 20 Sep 2004 @ 20:50:08 GMT
Subj: | | Re: CONNECT BY ..START WITH ( Equivalent in Teradata ) |
|
From: | | Walter, Todd A |
It is in V2R6.0. Not with START/CONNECT BY syntax because ANSI did it with different syntax.
WITH RECURSIVE All_Trips(Source, Destination,Cost, Depth) AS
(
SELECT Source, Destination, Cost, 0 FROM Flights
UNION ALL
SELECT All_Trips.Source,
Flights.Destination,
All_Trips.Cost + Flights.cost,
All_Trips.Depth + 1
FROM All_Trips, Flights /*Recursive reference*/
WHERE All_Trips.Destination = Flights.Source
)
SELECT * FROM All_Trips;
| |