Bird
0
0

Examine this dbt model SQL snippet:

medium📝 Debug Q6 of 15
dbt - Jinja in dbt
Examine this dbt model SQL snippet:
SELECT
  user_id,
  CASE
    WHEN age > 18 THEN 'adult'
    ELSE 'minor'
  END AS age_group
FROM users

What is the error in this snippet?
AMissing END keyword to close CASE statement.
BThere is no error; the syntax is correct.
CIncorrect use of ELSE without a preceding WHEN.
DCASE should be followed by a column name directly.
Step-by-Step Solution
Solution:
  1. Step 1: Review CASE syntax

    The snippet uses CASE with WHEN and ELSE clauses, properly closed with END.
  2. Step 2: Check for syntax errors

    All keywords are correctly placed and the CASE statement is properly terminated.
  3. Final Answer:

    No error; syntax is correct. -> Option B
  4. Quick Check:

    CASE with WHEN, ELSE, and END is valid [OK]
Quick Trick: CASE needs WHEN, ELSE, and END keywords [OK]
Common Mistakes:
MISTAKES
  • Omitting END keyword
  • Using CASE with direct condition without WHEN
  • Misplacing ELSE clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes