0
0
SQLquery~10 mins

Simple CASE syntax in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A90
B100
C70
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using a value other than 90 in WHEN clause.
Confusing CASE syntax with searched CASE.
2fill in blank
medium

Complete 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'
A'P'
B'F'
C'X'
D'A'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'F' which means fail instead of 'P'.
Omitting quotes around the character.
3fill in blank
hard

Fix 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'
A'18'
B'eighteen'
C18
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Putting 18 in quotes making it a string.
Using a variable name instead of a value.
4fill in blank
hard

Fill 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'
A50
B75
C100
D25
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping low and high values.
Using values not in options.
5fill in blank
hard

Fill 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'
A1
B2
C3
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 4 which is not mapped.
Mixing up the color codes.