0
0
SQLquery~10 mins

Nested CASE expressions 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 above 80 using a CASE expression.

SQL
SELECT CASE WHEN score [1] 80 THEN 'High' ELSE 'Low' END AS performance FROM results;
Drag options to blanks, or click blank then click option'
A=
B<
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will label scores below 80 as 'High'.
Using '=' will only label scores exactly 80 as 'High'.
2fill in blank
medium

Complete the code to return 'Medium' when score is between 50 and 80 using nested CASE expressions.

SQL
SELECT CASE WHEN score > 80 THEN 'High' WHEN score [1] 50 THEN 'Medium' ELSE 'Low' END AS performance FROM results;
Drag options to blanks, or click blank then click option'
A<
B>=
C=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' instead of '>=' will incorrectly classify scores below 50 as 'Medium'.
Using '=' only matches score exactly 50.
3fill in blank
hard

Fix the error in the nested CASE expression to correctly classify scores.

SQL
SELECT CASE WHEN score > 80 THEN 'High' WHEN score [1] 50 THEN 'Medium' ELSE 'Low' END AS performance FROM results;
Drag options to blanks, or click blank then click option'
A>=
B<=
C<
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' will incorrectly classify scores below 50 as 'Medium'.
Using '=' only matches score exactly 50.
4fill in blank
hard

Fill both blanks to classify scores into 'High', 'Medium', or 'Low' using nested CASE expressions.

SQL
SELECT CASE WHEN score [1] 80 THEN 'High' WHEN score [2] 50 THEN 'Medium' ELSE 'Low' END AS performance FROM results;
Drag options to blanks, or click blank then click option'
A>
B<=
C>=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the operators will misclassify scores.
Using '<=' in the first blank will cause wrong results.
5fill in blank
hard

Fill all three blanks to create a nested CASE expression that classifies scores into 'Excellent', 'Good', 'Average', or 'Poor'.

SQL
SELECT CASE WHEN score [1] 90 THEN 'Excellent' WHEN score [2] 75 THEN 'Good' WHEN score [3] 50 THEN 'Average' ELSE 'Poor' END AS performance FROM results;
Drag options to blanks, or click blank then click option'
A>=
B<
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for the first two blanks will misclassify scores.
Using '<=' instead of '>=' for the last blank will misclassify low scores.