Bird
0
0

Find the error in this nested CASE expression:

medium📝 Debug Q6 of 15
SQL - CASE Expressions
Find the error in this nested CASE expression:
SELECT CASE WHEN Marks > 75 THEN CASE WHEN Marks > 90 THEN 'Distinction' ELSE 'Pass' END ELSE 'Fail' FROM Students;
AIncorrect comparison operator used
BMissing END keyword for the outer CASE expression
CELSE clause is not allowed in nested CASE
DCASE expressions cannot be nested
Step-by-Step Solution
Solution:
  1. Step 1: Check CASE syntax

    Every CASE expression must end with an END keyword.
  2. Step 2: Analyze given query

    The inner CASE has END, but the outer CASE lacks its END keyword.
  3. Final Answer:

    Missing END keyword for the outer CASE expression -> Option B
  4. Quick Check:

    Each CASE needs matching END [OK]
Quick Trick: Every CASE requires END keyword [OK]
Common Mistakes:
  • Forgetting END for outer CASE
  • Misplacing ELSE clauses
  • Assuming nested CASE disallows ELSE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes