Skills101
← All practice quizzes

Quiz: Recursive CTEs

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

WITH RECURSIVE lets one query walk a hierarchy of any depth. Learn the anchor and recursive parts, how the loop stops, and the four classic uses — series, missing dates, org charts and paths.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    In a recursive CTE, how many times does the anchor query run?

  2. Question 2

    When does the recursion stop?

  3. Question 3

    What does this query return?

    WITH RECURSIVE t(n) AS (SELECT 2 UNION ALL SELECT n * 2 FROM t WHERE n < 16)
    SELECT MAX(n) FROM t;
    
  4. Question 4

    What does this query return?

    WITH RECURSIVE t(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM t WHERE n < 4)
    SELECT SUM(n) FROM t;
    
  5. Question 5

    To list everyone UNDER a manager, the recursive part joins on:

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →