Bird
0
0

Find the problem in this query:

medium📝 Debug Q7 of 15
SQL - CASE Expressions
Find the problem in this query:

SELECT product, price FROM Items ORDER BY CASE price WHEN > 100 THEN 1 ELSE 2 END;
AORDER BY cannot use CASE with numeric columns
BMissing ELSE clause in CASE
CIncorrect CASE WHEN syntax; cannot use comparison operator directly after WHEN
DMissing END keyword
Step-by-Step Solution
Solution:
  1. Step 1: Review CASE WHEN syntax

    WHEN expects a value to compare, not a condition with > operator.
  2. Step 2: Correct usage

    Use CASE WHEN price > 100 THEN 1 ELSE 2 END for conditions.
  3. Final Answer:

    Incorrect CASE WHEN syntax; cannot use comparison operator directly after WHEN -> Option C
  4. Quick Check:

    WHEN needs condition after WHEN keyword [OK]
Quick Trick: Use WHEN condition THEN, not WHEN value > x THEN [OK]
Common Mistakes:
  • Writing WHEN > 100 instead of WHEN price > 100
  • Omitting ELSE clause
  • Forgetting END keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes