Bird
0
0

Identify the error in this Simple CASE expression:

medium📝 Debug Q6 of 15
SQL - CASE Expressions
Identify the error in this Simple CASE expression:
SELECT CASE WHEN Status = 1 THEN 'Active' WHEN Status = 2 THEN 'Inactive' ELSE 'Unknown' END FROM Users;
AMissing END keyword
BIncorrect syntax: Simple CASE should not use conditions after WHEN
CELSE clause is not allowed in Simple CASE
DNo error, query is correct
Step-by-Step Solution
Solution:
  1. Step 1: Differentiate Simple and Searched CASE

    Simple CASE compares one expression to values; searched CASE uses conditions.
  2. Step 2: Check usage of WHEN clauses

    Using conditions after WHEN is for searched CASE, not Simple CASE.
  3. Final Answer:

    Incorrect syntax: Simple CASE should not use conditions after WHEN -> Option B
  4. Quick Check:

    Simple CASE uses values, not conditions [OK]
Quick Trick: Simple CASE uses values, not conditions after WHEN [OK]
Common Mistakes:
  • Mixing Simple and Searched CASE syntax
  • Ignoring difference between WHEN value and WHEN condition
  • Assuming ELSE is disallowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes