Bird
0
0

Find the error in this query:

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

SELECT * FROM Sales WHERE CASE WHEN region = 'North' THEN amount > 1000 ELSE amount < 500 END = TRUE;
AIncorrect use of comparison operator inside CASE
BMissing ELSE clause in CASE
CCASE cannot be used in WHERE clause
DIncorrect comparison of CASE result with TRUE
Step-by-Step Solution
Solution:
  1. Step 1: Understand CASE returns boolean

    CASE returns TRUE or FALSE based on conditions.
  2. Step 2: Check comparison with TRUE

    Comparing CASE result with TRUE is redundant and may cause errors.
  3. Step 3: Correct usage

    Use CASE directly in WHERE without '= TRUE'.
  4. Final Answer:

    Incorrect comparison of CASE result with TRUE -> Option D
  5. Quick Check:

    Use CASE directly in WHERE without '= TRUE' [OK]
Quick Trick: Don't compare CASE result to TRUE in WHERE [OK]
Common Mistakes:
  • Adding '= TRUE' after CASE
  • Omitting ELSE clause
  • Believing CASE is disallowed in WHERE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes