|
|
原帖由 grubbyoo 于 2010-4-24 20:38 发表 ![]()
其实是假的 ,效果还是有的
默认10个字符
with a as
(select t, n,
row_number() over(partition by n order by n,t) s,
count(1) over(partition by n) + 1 c
from (select sys_connect_by_path(n, ',') t, level n
from (select rownum n from dual connect by rownum < 10)
connect by nocycle n > prior n))
select ltrim (t, ','), ltrim(prior t, ',')
from a
where connect_by_isleaf = 1 and prior t is not null
connect by nocycle n + prior n = 10 - 1 and s + prior s = c
order by 1
这个求补集的思路真是太强大了,膜拜一下!有阵子没看到你了,以后要常来玩啊!
我把你最后一个CONNECT BY去掉:
with a as
(select t, n,
row_number() over(partition by n order by t) s,
count(1) over(partition by n) + 1 c
from (select sys_connect_by_path(n, ',') t, level n
from (select rownum n from dual connect by rownum < 10)
connect by nocycle n > prior n
)
)
SELECT ltrim (a.t, ','), ltrim(b.t, ',')
from a, a b
WHERE a.n + b.n = 10 - 1 AND a.s + b.s = b.c
/ |
|