|
6#
发了怎么没看到,再发一下
SQL> with t as (select chr(64 + level) n from dual connect by level <= 5),
2 s(lvl,str) as (select 1,n from t
3 union all
4 select lvl + 1,
5 s.str||t.n
6 from s,t
7 where lvl < 5
8 and instr(s.str,t.n)=0
9 )
10 select count(a.str||b.str||c.str)
11 from (select str ,substr(str,1,1) x,substr(str,2,1) y,substr(str,3,1) z, substr(str,4,1) u,substr(str,5,1) v from s where lvl = 5) a,
12 (select str ,substr(str,1,1) x,substr(str,2,1) y,substr(str,3,1) z, substr(str,4,1) u,substr(str,5,1) v from s where lvl = 5) b,
13 (select str ,substr(str,1,1) x,substr(str,2,1) y,substr(str,3,1) z, substr(str,4,1) u,substr(str,5,1) v from s where lvl = 5) c
14 where a.x <> b.x and b.x <> c.x and c.x <> a.x
15 and a.y <> b.y and b.y <> c.y and c.y <> a.y
16 and a.z <> b.z and b.z <> c.z and c.z <> a.z
17 and a.u <> b.u and b.u <> c.u and c.u <> a.u
18 and a.v <> b.v and b.v <> c.v and c.v <> a.v
19 /
COUNT(A.STR||B.STR||C.STR)
--------------------------
66240
|
|