🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Recursive CTEs: questions with answers

15 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. In a recursive CTE, how many times does the anchor query run?
  2. Q2. When does the recursion stop?
  3. Q3. What does this query return? (code)
  4. Q4. What does this query return? (code)
  5. Q5. To list everyone UNDER a manager, the recursive part joins on:
  6. Q6. Why can't a single self join list all of a CEO's indirect reports?
  7. Q7. Why is a calendar CTE LEFT JOINed to the sales table?
  8. Q8. The data has a loop: A manages B and B manages A. What is a safe fix in the query?
  9. Q9. What rule must the anchor and the recursive part follow?
  10. Q10. A filter WHERE level < 3 is written in the OUTER query instead of the recursive part. What happens?
  11. Q11. How many rows does this CTE produce: WITH RECURSIVE t(n) AS (SELECT 10 UNION ALL SELECT n - 3 FROM t WHERE n 1) SELECT FROM t?
  12. Q12. To walk UP from Arjun to the top manager, how does the recursive part join?
  13. Q13. A calendar CTE starts at '2026-01-01' and adds one day while d < '2026-01-31'. How many days does it produce?
  14. Q14. How does SQL Server write a recursive CTE?
  15. Q15. What is a downside of using UNION instead of UNION ALL inside a recursive CTE?