Bird
0
0

Identify the error in this SQL query:

medium📝 Debug Q14 of 15
SQL - CASE Expressions
Identify the error in this SQL query:
SELECT name, CASE salary > 10000 THEN 'Rich' ELSE 'Average' END AS status FROM users;
AMissing WHEN keyword after CASE
BMissing END keyword
CMissing ELSE keyword
DMissing AS keyword for alias
Step-by-Step Solution
Solution:
  1. Step 1: Check CASE syntax

    The CASE statement must have WHEN before the condition. Here, WHEN is missing.
  2. Step 2: Verify other parts

    END and ELSE are present, AS is used correctly, so no errors there.
  3. Final Answer:

    Missing WHEN keyword after CASE -> Option A
  4. Quick Check:

    CASE requires WHEN before condition [OK]
Quick Trick: Always write WHEN after CASE before condition [OK]
Common Mistakes:
  • Omitting WHEN keyword
  • Confusing ELSE with END
  • Forgetting AS alias

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes