--创建测试表,测试表中一行代表一种可能
点击(此处)折叠或打开
-
create table scott.test as select *
-
from ( select case when rownum=1 then 1 else 2 end a,
-
case when rownum=2 then 1 else 2 end b,
-
case when rownum=3 then 1 else 2 end c,
-
case when rownum=4 then 1 else 2 end d,
-
case when rownum=5 then 1 else 2 end e,
-
case when rownum=6 then 1 else 2 end f,
-
case when rownum=7 then 1 else 2 end g,
-
case when rownum=8 then 1 else 2 end h,
-
case when rownum=9 then 1 else 2 end i,
-
case when rownum=10 then 1 else 2 end j,
-
case when rownum=11 then 1 else 2 end k,
-
case when rownum=12 then 1 else 2 end l
-
from dual connect by rownum<=12
-
union all
-
select case when rownum=1 then 3 else 2 end a,
-
case when rownum=2 then 3 else 2 end b,
-
case when rownum=3 then 3 else 2 end c,
-
case when rownum=4 then 3 else 2 end d,
-
case when rownum=5 then 3 else 2 end e,
-
case when rownum=6 then 3 else 2 end f,
-
case when rownum=7 then 3 else 2 end g,
-
case when rownum=8 then 3 else 2 end h,
-
case when rownum=9 then 3 else 2 end i,
-
case when rownum=10 then 3 else 2 end j,
-
case when rownum=11 then 3 else 2 end k,
-
case when rownum=12 then 3 else 2 end l
- from dual connect by rownum<=12) a;
点击(此处)折叠或打开
-
select case
-
when a+b+c+d>e+f+g+h then --第1步
-
case when a+i+j+k>e+b+c+d --第2步
-
then
-
case when a!=i then ('a重') --第3步
-
when a=i then ('e轻') end
-
when a+i+j+k=e+b+c+d --第2步
-
then
-
case when f>g then ('g轻') --第3步
-
when f=g then ('h轻')
-
when f<g then ('f轻') end
-
when a+i+j+k<e+b+c+d --第2步
-
then
-
case when b>c then ('b重') --第3步
-
when b=c then ('d重')
-
when b<c then ('c重') end end
-
when a+b+c+d=e+f+g+h --第1步
-
then
-
case when a+i+j+k>e+b+c+d --第2步
-
then
-
case when i>j then ('i重') --第3步
-
when i=j then ('k重')
-
when i<j then ('j重') end
-
when a+i+j+k=e+b+c+d --第2步
-
then
-
case when a>l then ('l轻') --第3步
-
when a<l then ('l重') end
-
when a+i+j+k<e+b+c+d --第2步
-
then
-
case when i>j then ('j轻') --第3步
-
when i=j then ('k轻')
-
when i<j then ('i轻') end end
-
when a+b+c+d<e+f+g+h --第1步
-
then
-
case when a+i+j+k>e+b+c+d --第2步
-
then
-
case when b>c then ('c轻') --第3步
-
when b=c then ('d轻')
-
when b<c then ('b轻') end
-
when a+i+j+k=e+b+c+d --第2步
-
then
-
case when f>g then ('f重') --第3步
-
when f=g then ('h重')
-
when f<g then ('g重') end
-
when a+i+j+k<e+b+c+d --第2步
-
then
-
case when a!=i then ('a轻') --第3步
-
when a=i then ('e重') end end
-
end 假乒乓球,
-
test.*
- from scott.test;
点击(此处)折叠或打开
- /*
-
假乒乓球 A B C D E F G H I J K L
a轻 1 2 2 2 2 2 2 2 2 2 2 2
b轻 2 1 2 2 2 2 2 2 2 2 2 2
c轻 2 2 1 2 2 2 2 2 2 2 2 2
d轻 2 2 2 1 2 2 2 2 2 2 2 2
e轻 2 2 2 2 1 2 2 2 2 2 2 2
f轻 2 2 2 2 2 1 2 2 2 2 2 2
g轻 2 2 2 2 2 2 1 2 2 2 2 2
h轻 2 2 2 2 2 2 2 1 2 2 2 2
i轻 2 2 2 2 2 2 2 2 1 2 2 2
j轻 2 2 2 2 2 2 2 2 2 1 2 2
k轻 2 2 2 2 2 2 2 2 2 2 1 2
l轻 2 2 2 2 2 2 2 2 2 2 2 1
a重 3 2 2 2 2 2 2 2 2 2 2 2
b重 2 3 2 2 2 2 2 2 2 2 2 2
c重 2 2 3 2 2 2 2 2 2 2 2 2
d重 2 2 2 3 2 2 2 2 2 2 2 2
e重 2 2 2 2 3 2 2 2 2 2 2 2
f重 2 2 2 2 2 3 2 2 2 2 2 2
g重 2 2 2 2 2 2 3 2 2 2 2 2
h重 2 2 2 2 2 2 2 3 2 2 2 2
i重 2 2 2 2 2 2 2 2 3 2 2 2
j重 2 2 2 2 2 2 2 2 2 3 2 2
k重 2 2 2 2 2 2 2 2 2 2 3 2
l重 2 2 2 2 2 2 2 2 2 2 2 3 -
*/