WITH RECURSIVE query_name AS (SELECT…)
recursive
• No join
in recursive branch—use comma-join (,
)recursive
cycle … restrict
• No using …
sub-clauseusing …
sub-clauserow_number() over()
to implement top-N queryT131 also allows recursive views, which are not yet covered on this page.
Tutorial: With
— Organize Complex Queries
Product specific forms: cycle…set…to…default, cycle…restrict
.
T131, “Recursive query”, is an optional feature in ISO/IEC 9075:2016-2. It first appeared in SQL:1999.0
The essence of SQL tuning in 200 pages
Buy now!
(paperback and/or PDF)
Paperback also available at Amazon.com.
Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »
SQL:1999, formerly known as SQL3 (Eisenberg, Melton)