|
13 #
这题太容易了。。。
SQL> with t as (select 'M' a,'F' b,'S' c,'D' d from dual),
2 r as (select level n from dual connect by level <=4),
3 s as (select rownum rn,a||n a,b||n b,c||n c,d||n d from t,r),
4 f as ( select s1.a,s2.b,s3.c
5 from s s1,s s2,s s3
6 where s1.rn <> s2.rn
7 and s2.rn <> s3.rn
8 and s1.rn <> s3.rn
9 union all
10 select s1.a,s2.b,s3.d
11 from s s1,s s2,s s3
12 where s1.rn <> s2.rn
13 and s2.rn <> s3.rn
14 and s1.rn <> s3.rn )
15 select
16 --f1.a a1,f1.b b1,f1.c c1,f2.a a2,f2.b b2,f2.c c2,f3.a a3,f3.b b3,f3.c c3
17 count(*)
18 from f f1,f f2,f f3
19 where f1.a <> f2.a
20 and f2.a <> f3.a
21 and f1.a <> f3.a
22 and f1.b <> f2.b
23 and f2.b <> f3.b
24 and f1.b <> f3.b
25 and f1.c <> f2.c
26 and f2.c <> f3.c
27 and f1.c <> f3.c
28 /
COUNT(*)
----------
12480 |
|