Bird
0
0

Find the error in this SQL query:

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

SELECT student_name FROM Students ORDER BY CASE student_name WHEN 'John' THEN 1 WHEN 'Jane' THEN 2 ELSE 3
AIncorrect column name used in ORDER BY
BMissing END keyword to close the CASE expression
CCASE cannot be used in ORDER BY clause
DTHEN values must be strings, not numbers
Step-by-Step Solution
Solution:
  1. Step 1: Review CASE syntax

    CASE expressions must end with the END keyword.
  2. Step 2: Check query

    The query is missing END after the ELSE clause.
  3. Final Answer:

    Missing END keyword to close the CASE expression -> Option B
  4. Quick Check:

    CASE must end with END [OK]
Quick Trick: Always close CASE with END [OK]
Common Mistakes:
  • Forgetting END keyword
  • Misusing THEN values
  • Assuming CASE not allowed in ORDER BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes