|
方法一:
- with t as
- (select 'A' c1
- from dual
- union all
- select 'B'
- from dual
- union all
- select 'C'
- from dual
- union all
- select 'D'
- from dual)
- select substr(sys_connect_by_path(c1, ','), 2)
- from t
- where level = 4
- connect by nocycle prior c1 != c1;
复制代码 方法二:
- WITH tmp AS
- (select 'A' as word
- from dual
- union all
- select 'B'
- from dual
- union all
- select 'C'
- from dual
- union all
- select 'D'
- from dual)
- select a.word, b.word, c.word, d.word
- from tmp a, tmp b, tmp c, tmp d
- where a.word <> b.word
- and a.word <> c.word
- and a.word <> d.word
- and b.word <> c.word
- and b.word <> d.word
- and c.word <> d.word
- order by 1, 2, 3, 4;
复制代码
|
|