
Answer-first summary for fast verification
Answer: CONNECT BY, WITH
The question asks for SQL commands to write a recursive query when the number of hierarchy levels is unknown. CONNECT BY (A) is Snowflake's hierarchical query operator specifically designed for recursive operations on hierarchical data. WITH (E) is used for Common Table Expressions (CTEs), including recursive CTEs that can traverse hierarchical data with unknown levels. The community discussion shows 100% consensus on AE, with upvoted comments confirming that CONNECT BY and the recursive CTE portion of WITH are the correct approaches. LISTAGG (B) is for string aggregation, not recursion. MATCH_RECOGNIZE (C) is for pattern matching in sequences. QUALIFY (D) is for filtering window function results.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.