With temp1 as(
Select rownum my_value_1 from dual
Connect by rownum<=50)
,temp2 as(
select rownum my_rn, my_value_1 from temp1
where ((mod(my_value_1,2)<>0 and mod(my_value_1,3)<>0)
or my_value_1 in(2,3)) and my_value_1<>1
)
,temp3 as(
select my_rn,my_value_1,wm_concat(my_value_1) over(order by my_rn) my_value_2 from temp2)
,temp4 as(
select rownum my_rn_1 from dual connect by rownum<=(select count(*) from temp2)
)
,temp5 as(
select my_rn,my_value_1,my_value_2, decode(mod(my_value_1,regexp_substr(my_value_2,'[^,]+',1,my_rn_1)) ,0,1,0) total_score,my_rn_1 from temp3 a, temp4 b
where a.my_rn>b.my_rn_1)
select my_rn,my_value_1,sum(total_score) from temp5
group by my_rn,my_value_1
having sum(total_score)=0
order by 1
用sql语句来完成求质数
最新推荐文章于 2021-12-24 12:06:45 发布