Bird
0
0

Find the error in this query:

medium📝 Debug Q7 of 15
SQL - CASE Expressions
Find the error in this query:
SELECT id, CASE WHEN age >= 18 THEN 'Adult' ELSE 'Minor' AS age_group FROM users;
AMissing ELSE keyword
BMissing END keyword before alias
CIncorrect alias name
DMissing WHEN keyword
Step-by-Step Solution
Solution:
  1. Step 1: Check CASE statement completeness

    The CASE expression must end with END before alias; here END is missing.
  2. Step 2: Confirm other parts

    WHEN and ELSE are present; alias is valid; only END is missing.
  3. Final Answer:

    Missing END keyword before alias -> Option B
  4. Quick Check:

    CASE expressions must end with END [OK]
Quick Trick: Always close CASE with END before alias [OK]
Common Mistakes:
  • Omitting END keyword
  • Placing alias inside CASE
  • Missing WHEN or ELSE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes