Recall & Review
beginner
What is the purpose of the Searched CASE syntax in SQL?
It allows you to perform conditional logic in SQL queries by evaluating multiple conditions and returning a result for the first true condition.
Click to reveal answer
beginner
Write the basic structure of a Searched CASE expression.
CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ... ELSE default_result END
Click to reveal answer
intermediate
How does the Searched CASE differ from the Simple CASE syntax?
Searched CASE evaluates boolean conditions in each WHEN clause, while Simple CASE compares an expression to fixed values.
Click to reveal answer
beginner
Can the ELSE clause in a Searched CASE be omitted? What happens then?
Yes, it can be omitted. If no WHEN condition matches, the CASE expression returns NULL.
Click to reveal answer
beginner
Give a real-life example where Searched CASE is useful.
For example, assigning grades based on score ranges: CASE WHEN score >= 90 THEN 'A' WHEN score >= 80 THEN 'B' ELSE 'F' END
Click to reveal answer
What does the Searched CASE syntax evaluate in each WHEN clause?
✗ Incorrect
Searched CASE evaluates boolean conditions in each WHEN clause to decide which result to return.
What will the CASE expression return if no WHEN condition matches and ELSE is omitted?
✗ Incorrect
If ELSE is omitted and no WHEN condition matches, the CASE expression returns NULL.
Which keyword starts a searched CASE expression?
✗ Incorrect
The searched CASE expression always starts with the keyword CASE.
In Searched CASE, what does the ELSE clause do?
✗ Incorrect
ELSE provides a default result when none of the WHEN conditions are true.
Which of these is a valid Searched CASE syntax?
✗ Incorrect
Option C correctly uses WHEN with a condition and an ELSE clause.
Explain how the Searched CASE syntax works in SQL and when you would use it.
Think about how you decide between multiple choices based on conditions.
You got /4 concepts.
Write a Searched CASE expression that categorizes a numeric score into 'High', 'Medium', or 'Low'.
Use score ranges like >80, >50, else.
You got /4 concepts.