1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. In a recursive CTE written as a seed query unioned with a…

Added 30 Nov -0001

In a recursive CTE written as a seed query unioned with a recursive term, what ends the recursion?

  1. The recursive term returning no new rows, which stops the iteration Correct answer
  2. A fixed recursion depth of 100 iterations built into every engine
  3. The UNION ALL operator, which stops once duplicates have been seen
  4. An explicit maximum recursion option that every recursive CTE must set

Correct answer

A. The recursive term returning no new rows, which stops the iteration

19 views

MCQSEXAM

Explanation

A recursive CTE evaluates the seed, then repeatedly applies the recursive term to the rows produced by the previous iteration, stopping when an iteration returns no rows. UNION ALL keeps duplicates, so a cycle in the data recurses forever unless the query tracks visited keys. Some engines allow an iteration cap as a hint, but the standard mechanism is the empty step.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs