[sql]代码库
create table #users (name char(2),value char(1),id number);
insert into #users values('甲','a',1);
insert into #users values('乙','b',2);
insert into #users values('丙','c',3);
insert into #users values('丁','d',4);
commit;
--2个元素全排列
select o.p as "排列" from
(select replace (sys_connect_by_path( value, ',' ) , ',' ) p
from #users connect by nocycle value != prior value) o
where length(o.p) =2;
--3个元素全排列
select o.p as "排列" from
(select replace (sys_connect_by_path( value, ',' ) , ',' ) p
from #users connect by nocycle value != prior value) o
where length(o.p) =3;
--4个元素全排列
select o.p as "排列" from
(select replace (sys_connect_by_path( value, ',' ) , ',' ) p
from #users connect by nocycle value != prior value) o
where length(o.p) =4;
by: 发表于:2017-09-22 09:43:15 顶(0) | 踩(0) 回复
??
回复评论