|
- bill@ORCL> with b as (
- 2 select rownum-1 n from dual connect by rownum<=10),
- 3 p as (
- 4 select level n from dual where (level>=2 and mod(level, 2)<>0 and mod(level, 3)<>0 and mod(level, 5)<>0) or level in (2, 3, 5) connect by level<=23),
- 5 tmp as (
- 6 select d1.n||d2.n||d3.n d
- 7 from b d1, b d2, b d3, p
- 8 where d1.n<>d2.n
- 9 and d1.n<>d3.n
- 10 and d2.n<>d3.n
- 11 and d1.n+d2.n+d3.n=p.n),
- 12 t (d) as (
- 13 select d
- 14 from tmp
- 15 where not d like '0%'
- 16 union all
- 17 select t.d||substr(tmp.d, -1)
- 18 from t, tmp
- 19 where substr(t.d, -2)=substr(tmp.d, 1, 2)
- 20 and instr(t.d, substr(tmp.d, -1))=0)
- 21 select max(to_number(d)) from t;
- MAX(TO_NUMBER(D))
- -----------------
- 98652470
- 已用时间: 00: 00: 00.09
复制代码 |
|