Can we use the output of one recursive query into another recursive query?
问题 I wanted to find the topological sort of a DAG. create table topo( v1 int, v2 int ); Insert into topo values (1,3),(2,5),(3,4),(4,5),(4,6),(5,7),(6,5),(7,null) WITH RECURSIVE path(S,d) AS( select t1.v1, 0 from topo t1 left outer join topo as t2 on t1.v1=t2.v2 where t2.v2 IS null UNION ALL select distinct t1.v2, path.d + 1 from path inner join topo as t1 on t1.v1=path.S ) select S from path group by S order by MAX(d); This code gives the output of the topological order of a graph. Now i want