|
把上面的思路, 用SQL完整的描述出来:
with t as (select column_value p from table(pkg_prim2.seive_numlist(5000)) )
,ts as (select row_number() over (order by p) r, p, sum(p) over (order by p) s from t)
--select * from ts
,t1 as (select t1.r r1, t2.r r2, t1.p p1, t2.p p2, t1.s s1, t2.s s2, t1.r-t2.r rcnt, t1.s-t2.s thenumber from ts t1, (select * from ts union all select 0,0,0 from dual) t2
where t1.r - t2.r > 21 and t1.s-t2.s<=1000000
and pkg_prim2.isprim(t1.s-t2.s)=0)
select * from t1 where rcnt = (select max(rcnt) from t1)
R1 R2 P1 P2 S1 S2 RCNT THENUMBER
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
546 3 3931 5 997661 10 543 997651
Executed in 6.219 seconds |
|