エラトステネスのふるいで、 100未満の素数を求める。
with WorkView as (
select RowNum+1 as Val from dual
connect by Level < 99)
select Val from WorkView a
where not exists(select 1 from WorkView b
where b.Val <= sqrt(a.Val)
and mod(a.Val,b.Val) = 0);
階層問い合わせで、2から99までの自然数の集合を作成して、 エラトステネスのふるいで、100未満の素数を出力してます。