AI engineering glossary · SQL databases

What is Recursive CTE?

Recursive CTE: A common table expression that refers to itself: an anchor query gives starting rows, and a recursive part repeatedly adds rows built from the previous step until nothing new appears. It walks hierarchies such as org charts.

Level: advancedTopic: SQL databases

Recursive CTE: an example

Starting from the CEO row, each step adds employees whose manager_id matches the previous level, producing the whole reporting tree.

Related terms

More SQL databases terms

Where you learn it

Recursive CTE is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.