Skip to content

Commit 0cf2c89

Browse files
[ADD] Recursive CTE
1 parent 7764728 commit 0cf2c89

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

classes/31-recursive-cte.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Name of the table in memory
2+
-- Fields of the table
3+
WITH RECURSIVE countdown(val) AS (
4+
-- Initialization => First level o initial values
5+
-- VALUES(5)
6+
SELECT 5 AS val
7+
UNION
8+
-- Recursive query
9+
SELECT val - 1
10+
FROM countdown
11+
WHERE val > 1
12+
)
13+
14+
-- Select of the fields
15+
SELECT *
16+
FROM countdown;

0 commit comments

Comments
 (0)