Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to return 'High' when score is 90, else 'Other'.
SQL
SELECT CASE score WHEN [1] THEN 'High' ELSE 'Other' END AS grade FROM exams;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a value other than 90 in WHEN clause.
Confusing CASE syntax with searched CASE.
✗ Incorrect
The CASE expression compares score to 90 and returns 'High' if it matches.
2fill in blank
mediumComplete the code to return 'Pass' when status is 'P', else 'Fail'.
SQL
SELECT CASE status WHEN [1] THEN 'Pass' ELSE 'Fail' END AS result FROM tests;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'F' which means fail instead of 'P'.
Omitting quotes around the character.
✗ Incorrect
The CASE checks if status equals 'P' to return 'Pass'.
3fill in blank
hardFix the error in the CASE expression to return 'Adult' when age is 18.
SQL
SELECT CASE age WHEN [1] THEN 'Adult' ELSE 'Minor' END AS category FROM people;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting 18 in quotes making it a string.
Using a variable name instead of a value.
✗ Incorrect
Since age is a number, WHEN should compare to 18 without quotes.
4fill in blank
hardFill both blanks to return 'Low', 'Medium', or 'High' based on score.
SQL
SELECT CASE score WHEN [1] THEN 'Low' WHEN [2] THEN 'High' ELSE 'Medium' END AS level FROM results;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping low and high values.
Using values not in options.
✗ Incorrect
Score 25 returns 'Low', 100 returns 'High', others 'Medium'.
5fill in blank
hardFill all three blanks to return 'Red', 'Green', or 'Blue' based on color_code.
SQL
SELECT CASE color_code WHEN [1] THEN 'Red' WHEN [2] THEN 'Green' WHEN [3] THEN 'Blue' ELSE 'Unknown' END AS color_name FROM palette;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 4 which is not mapped.
Mixing up the color codes.
✗ Incorrect
Color codes 1, 2, 3 correspond to Red, Green, Blue respectively.