|
〇〇 发表于 2015-8-14 05:48 ![]()
88楼为什么慢
GREATEST(C3,C4,C5,C6,C7,C8,C9,C10)
----------------------------------
985432107
Elapsed: 00:00:00.08
with t as(select level-1 l from dual connect by level<=10)
,t3 as(select distinct a.l||b.l||c.l l from t a,t b,t c where a.l*a.l/2>b.l*c.l
and a.l<>b.l and b.l<>c.l and c.l<>a.l)
,t4 as(select distinct a.l||substr(b.l,-1) l from t3 a,t3 b
where substr(a.l,-2,2)=substr(b.l,1,2) and instr(a.l,substr(b.l,-1))=0)
,t5 as(select distinct a.l||substr(b.l,-1) l from t4 a,t3 b
where substr(a.l,-2,2)=substr(b.l,1,2) and instr(a.l,substr(b.l,-1))=0)
,t6 as(select distinct a.l||substr(b.l,-1) l from t5 a,t3 b
where substr(a.l,-2,2)=substr(b.l,1,2) and instr(a.l,substr(b.l,-1))=0)
,t7 as(select distinct a.l||substr(b.l,-1) l from t6 a,t3 b
where substr(a.l,-2,2)=substr(b.l,1,2) and instr(a.l,substr(b.l,-1))=0)
,t8 as(select distinct a.l||substr(b.l,-1) l from t7 a,t3 b
where substr(a.l,-2,2)=substr(b.l,1,2) and instr(a.l,substr(b.l,-1))=0)
,t9 as(select distinct a.l||substr(b.l,-1) l from t8 a,t3 b
where substr(a.l,-2,2)=substr(b.l,1,2) and instr(a.l,substr(b.l,-1))=0)
,t10 as(select distinct a.l||substr(b.l,-1) l from t9 a,t3 b
where substr(a.l,-2,2)=substr(b.l,1,2) and instr(a.l,substr(b.l,-1))=0)
select coalesce(
(select max(to_number(l)) from t10)
,(select max(to_number(l)) from t9)
,(select max(to_number(l)) from t8)
,(select max(to_number(l)) from t7)
,(select max(to_number(l)) from t6)
,(select max(to_number(l)) from t5)
,(select max(to_number(l)) from t4)
,(select max(to_number(l)) from t3)
) as num
from dual;
NUM
----------
985432107
Elapsed: 00:00:00.03
|
|