|
前面有一行 4,2,2 写错了,应该是 4,2,4
SQL> with t as (select level-1 n from dual connect by level <=10),
2 t1 as (
3 select str,to_number(substr(str,1,a)) a,to_number(substr(str,a+1,b)) b, to_number(substr(str,a+b+1,c)) c
4 from (
5 select replace(sys_connect_by_path(n,','),',','') str
6 from t
7 where level = 10
8 connect by nocycle prior n <> n
9 ) s,
10 (select 2 a,4 b, 4 c from dual
11 union all
12 select 4,2,4 from dual
13 union all
14 select 3,3,4 from dual
15 ) r
16 where to_number(substr(str,1,a)) + to_number(substr(str,a+1,b)) = to_number(substr(str,a+b+1,c))
17 )
18 select *
19 from t1
20 where c = (select max(c) from t1)
21 /
STR A B C
-------------------------------------------------------------------------------- ---------- ---------- ----------
3459876021 34 5987 6021
3759846021 37 5984 6021
4359786021 43 5978 6021
4859736021 48 5973 6021
5934876021 5934 87 6021
5937846021 5937 84 6021
5943786021 5943 78 6021
5948736021 5948 73 6021
5973486021 5973 48 6021
5978436021 5978 43 6021
5984376021 5984 37 6021
5987346021 5987 34 6021
7359486021 73 5948 6021
7859436021 78 5943 6021
8459376021 84 5937 6021
8759346021 87 5934 6021
16 rows selected
|
|