1
を選択SQLite3のが、のVerticaに編集にVertica私は私が「1からNまでの番号を持つテーブルを作成し、素数に</strong></p> <p>を選択する必要がありますのVerticaのバージョン8+</p> <p><strong>に取り組んでいる数字でテーブルを生成&素数
https://forum.vertica.com/discussion/206185/recursive-queries
WITH再帰許可していないことをやって達成しまし:
WITH seq AS (
SELECT n FROM (
SELECT ROW_NUMBER() OVER() AS n
FROM (
SELECT 1
FROM (
SELECT date(0) + INTERVAL '1 second' AS i
UNION ALL
SELECT date(0) + INTERVAL '100 seconds' AS i
) _
TIMESERIES tm AS '1 second' OVER(ORDER BY i)
) _
) _
WHERE n > 1 -- 1 is not prime number
)
SELECT n
FROM (SELECT n FROM seq) _
WHERE n NOT IN (
SELECT n FROM (
SELECT s1.n AS n, s2.n AS n2
FROM seq AS s1
CROSS JOIN seq AS s2
ORDER BY n, n2
) _
WHERE n2 < n AND n % n2 = 0
)
ORDER BY n