By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table test (Id char);
insert into test values('A');
1 rows affected
insert into test values('B');
1 rows affected
insert into test values('C');
1 rows affected
insert into test values('D');
1 rows affected
insert into test values('E');
1 rows affected
SELECT id, PRIOR id AS id2
FROM test
WHERE LEVEL = 2
CONNECT BY NOCYCLE PRIOR id > id
ORDER BY id, id2
ID | ID2 |
---|---|
A | B |
A | C |
A | D |
A | E |
B | C |
B | D |
B | E |
C | D |
C | E |
D | E |