PrepZone Logo
PrepZone
Back to Database

Database · Medium

What is a CTE? How do recursive CTEs work?

DatabaseSQLFresher

Answer preview

A CTE (Common Table Expression) is a named temporary result set defined with WITH that exists only for the duration of the statement. A recursive CTE adds RECURSIVE and references itself, letting one query walk a hierarchy or generate a sequence of unknown depth.…