1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| With TACHE as
(
select 1 as TACHEID, 'Tache 1' as TACHENAME from dual union all
select 2 , 'Tache 2' from dual union all
select 3 , 'Tache 3' from dual union all
select 4 , 'Tache 4' from dual union all
select 5 , 'Tache 5' from dual union all
select 6 , 'Tache 6' from dual
)
, RELATION as
(
select 1 as TACHEIDPERE, 2 as TACHEIDFILS from dual union all
select 1 , 3 from dual union all
select 1 , 4 from dual union all
select 2 , 5 from dual union all
select 3 , 6 from dual union all
select 4 , 6 from dual
)
select level
, t1.TACHENAME as TACHENAMEPERE
, t2.TACHENAME as TACHENAMEFILS
from RELATION r
inner join tache t1
on t1.TACHEID = r.TACHEIDPERE
inner join tache t2
on t2.TACHEID = r.TACHEIDFILS
start with tacheidpere = 1
connect by tacheidpere = prior tacheidfils;
LEVEL TACHENAMEPERE TACHENAMEFILS
---------- ------------- -------------
1 Tache 1 Tache 2
2 Tache 2 Tache 5
1 Tache 1 Tache 3
2 Tache 3 Tache 6
1 Tache 1 Tache 4
2 Tache 4 Tache 6 |
Partager