「Postgres入門」WITH RECURSIVEで再帰クエリを実行する
SQL構文下記
SQL構文 WITH RECURSIVE kdf_tbl(n) AS ( VALUES (1) UNION ALL SELECT n+1 FROM kdf_tbl WHERE n < 100 ) SELECT sum(n) FROM kdf_tbl; 実行結果 sum 5050
Coding Changes the World
SQL構文下記
SQL構文 WITH RECURSIVE kdf_tbl(n) AS ( VALUES (1) UNION ALL SELECT n+1 FROM kdf_tbl WHERE n < 100 ) SELECT sum(n) FROM kdf_tbl; 実行結果 sum 5050