Bird
0
0

Which of the following correctly demonstrates the syntax of a searched CASE expression in SQL?

easy📝 Syntax Q3 of 15
SQL - CASE Expressions
Which of the following correctly demonstrates the syntax of a searched CASE expression in SQL?
ACASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 END ELSE result3
BCASE expression WHEN value1 THEN result1 WHEN value2 THEN result2 ELSE result3 END
CCASE WHEN condition1 THEN result1 ELSEIF condition2 THEN result2 ELSE result3 END
DCASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ELSE result3 END
Step-by-Step Solution
Solution:
  1. Step 1: Identify searched CASE syntax

    Searched CASE uses WHEN conditions followed by THEN results, ending with END.
  2. Step 2: Check options

    CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ELSE result3 END correctly shows multiple WHEN conditions with THEN results and an ELSE clause before END.
  3. Final Answer:

    CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ELSE result3 END -> Option D
  4. Quick Check:

    Is the ELSE clause before END and conditions after WHEN? [OK]
Quick Trick: WHEN conditions THEN results, ELSE optional, END mandatory [OK]
Common Mistakes:
  • Using ELSE outside END
  • Confusing searched CASE with simple CASE syntax
  • Using ELSEIF instead of multiple WHEN

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes