Quantcast
Viewing latest article 26
Browse Latest Browse All 207

What are use cases for Recursive CTEs?

I am looking for examples of why you would use a recursive CTE, but the dozens of examples I have found in my web searching basically reduce to two:

  • Generating a sequence
  • Iterating through an employee hierarchy

I did find one example where a recursive CTE is used to split a string by commas, which is by far the most interesting (db<>fiddles: SQL Server, Postgres).

Are there examples of recursive CTEs which are not basically one of the above?


Viewing latest article 26
Browse Latest Browse All 207

Trending Articles