|
with t as(select level n,ceil(level/2)r,mod(level,2)+1 c from dual connect by level<=4)
,line as(
select rownum rn,t.n p1,t1.n p2 from t,t t1
where
t.n<t1.n and abs(t.r-t1.r)<=1 and abs(t.c-t1.c)<=1)
select * from line,line line2
where line.rn<line2.rn and
line.p1 in( line2.p1 ,line2.p1 )
or line.p2 in( line2.p1 ,line2.p1 )
;
RN P1 P2 RN P1 P2
----- ---------- ---------- ---------- ---------- ----------
1 1 2 2 1 3
1 1 2 3 1 4
1 1 2 4 2 3
1 1 2 5 2 4
2 1 3 3 1 4
2 1 3 6 3 4
4 2 3 5 2 4
4 2 3 6 3 4 |
|