Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
SQL - CASE Expressions
Identify the error in this query:
SELECT product, CASE price > 50 THEN 'Expensive' ELSE 'Cheap' END AS cost_category FROM products;
AMissing END keyword
BMissing WHEN keyword after CASE
CMissing ELSE keyword
DIncorrect alias name
Step-by-Step Solution
Solution:
  1. Step 1: Check CASE syntax

    CASE must be followed by WHEN before condition; here WHEN is missing.
  2. Step 2: Verify other parts

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

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

    CASE requires WHEN before condition [OK]
Quick Trick: Always use WHEN after CASE [OK]
Common Mistakes:
  • Omitting WHEN keyword
  • Forgetting END keyword
  • Misplacing ELSE clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes