1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| With Client as
(
select 1 as ID, 'B' as IDCODE, 1 as IDMGR, 'B' as MCODE, 8 as zone from dual union all
select 2 , 'B' , 3 , 'B' , 8 from dual union all
select 3 , 'B' , 3 , 'B' , 8 from dual union all
select 4 , 'B' , 3 , 'B' , 8 from dual union all
select 5 , 'B' , 4 , 'B' , 8 from dual
)
select ID, IDCODE, IDMGR, MCODE, ZONE, prior ID, prior IDMGR
from CLIENT
start with ID = 5
and IDCODE = 'B'
and zone = 8
connect by nocycle
prior IDMGR = ID
and prior MCODE = IDCODE;
ID I IDMGR M ZONE PRIORID PRIORIDMGR
---------- - ---------- - ---------- ---------- ----------
5 B 4 B 8
4 B 3 B 8 5 4 |
Partager