Answer
A recursive CTE can refer to its own result to process hierarchical or iterative data. • It has a non-recursive starting term. • A recursive term repeatedly uses rows produced so far. • The query must contain a condition that eventually stops producing new rows.
💡 SQL Example
WITH RECURSIVE numbers(n) AS (VALUES (1) UNION ALL SELECT n + 1 FROM numbers WHERE n < 5) SELECT n FROM numbers;
Result
1
2
3
4
5
⚡ Quick Revision
A recursive CTE grows a result from a base term until no new rows are produced.