Patrick Wolf wrote about the newest Apex release, which contains a 11.2 db engine, so I had to play with recursive queries 😉
with t(x) as (select 1 from dual
union all
select x+1 from t where x<5 )
select x from t;
X
1
2
3
4
5
with t(x,y) as (select 1 x, 1 y from dual
union all
select x+1,y*(x+1) from t where x<5 )
select x,y "X!" from t;
X X!
1 1
2 2
3 6
4 24
5 120
with t(r,x,y) as (select 1,1,1 from dual
union all
select r+1,y,x+y from t where r<5)
select x fib from t
FIB
1
1
2
3
5
with t1(x) as (select 1 from dual
union all
select x+1 from t1 where x<4),
t2(x,y,z) as (select x, 1,x from t1
union all
select x,y+1,x*(y+1) from t2 where y<2)
select listagg(z,';') within group (order by x) s from t2 group by y;
S
1;2;3;4
2;4;6;8
Pingback: Laurent Schneider » connect by and recursive with (part 2)