

Recursive CTEs are one of the most powerful — and most misunderstood — concepts in SQL.
This practice sheet is designed to help you truly understand how recursion works, not just write queries that “somehow run”.
The sheet is structured in a progressive manner so learners at all levels can build confidence step by step.
You’ll start with foundation-building problems that focus purely on recursive thinking:
Each problem includes a clear expected output, a clean SQL solution, and a step-by-step explanation of how the recursion evolves at every iteration.
Once the fundamentals are clear, you’ll move to applied use cases:
Here, the focus is not just the final answer, but how the recursive CTE grows row by row — exactly the way interviewers expect you to explain it.
This practice sheet is designed to be followed in sequence for maximum clarity and confidence.
Step 1: Start with Part A (Foundations)
Begin with the 15 fundamental problems to understand:
Do not rush this section. The goal is to mentally trace each iteration, not just reach the final output.
Step 2: Move to Part B – Section A (Applied Scenarios)
Once you’re comfortable with the basics, practice:
This step bridges the gap between abstract recursion and real-world datasets.
Step 3: Finish with Part B – Section B (Interview Problems)
Use the interview problems as your final checkpoint:
Following this roadmap helps ensure you build both technical correctness and confidence in your explanations.
This is a hands-on, thinking-first practice sheet.
You’re encouraged to:
This approach trains you not just to use recursive CTEs, but to reason through them confidently — a skill that directly translates to interviews and real-world SQL work.
If recursive CTEs have ever felt confusing or intimidating, this practice sheet will help you break that barrier with clarity and confidence.