Recall & Review
beginner
What is the purpose of the Simple CASE syntax in SQL?
The Simple CASE syntax helps you choose a value based on matching a single expression to different possible values, similar to a multiple-choice decision.
Click to reveal answer
beginner
Write the basic structure of a Simple CASE expression in SQL.
CASE expression WHEN value1 THEN result1 WHEN value2 THEN result2 ... ELSE default_result END
Click to reveal answer
intermediate
What happens if none of the WHEN conditions match and there is no ELSE clause in a Simple CASE expression?
The CASE expression returns NULL if no WHEN condition matches and there is no ELSE clause.
Click to reveal answer
intermediate
How is Simple CASE different from Searched CASE in SQL?
Simple CASE compares one expression to multiple values. Searched CASE evaluates multiple boolean conditions independently.
Click to reveal answer
beginner
Example: What will this SQL return? <br>
SELECT CASE grade WHEN 'A' THEN 'Excellent' WHEN 'B' THEN 'Good' ELSE 'Other' END AS performance FROM students;
It returns 'Excellent' if grade is 'A', 'Good' if grade is 'B', and 'Other' for any other grade.
Click to reveal answer
What keyword starts a Simple CASE expression in SQL?
✗ Incorrect
The Simple CASE expression always starts with the keyword CASE.
In Simple CASE, what does the expression after CASE represent?
✗ Incorrect
The expression after CASE is compared to each WHEN value to find a match.
What does the ELSE clause do in a Simple CASE expression?
✗ Incorrect
ELSE provides a default result when no WHEN condition matches.
If no WHEN matches and no ELSE is provided, what is returned?
✗ Incorrect
Without ELSE, CASE returns NULL if no match is found.
Which of these is a valid Simple CASE expression?
✗ Incorrect
Option C uses Simple CASE syntax correctly.
Explain how the Simple CASE syntax works in SQL and give a real-life example.
Think about choosing an output based on one value matching several options.
You got /5 concepts.
Describe the difference between Simple CASE and Searched CASE expressions in SQL.
Focus on how conditions are checked in each type.
You got /3 concepts.