Complete the code to create a computed column named 'status' that shows 'Adult' if age is 18 or more, otherwise 'Minor'.
SELECT name, age, CASE WHEN age [1] 18 THEN 'Adult' ELSE 'Minor' END AS status FROM people;
The CASE statement checks if age is greater than or equal to 18 to label as 'Adult'. Otherwise, it labels as 'Minor'.
Complete the code to assign 'High' to scores above 80, otherwise 'Low'.
SELECT student, score, CASE WHEN score [1] 80 THEN 'High' ELSE 'Low' END AS performance FROM results;
The CASE checks if score is greater than 80 to assign 'High'. Otherwise, it assigns 'Low'.
Fix the error in the CASE statement to correctly label 'Pass' for marks 50 or more, else 'Fail'.
SELECT student, marks, CASE WHEN marks [1] 50 THEN 'Pass' ELSE 'Fail' END AS result FROM exams;
The correct operator is '>=' to include marks equal to 50 as 'Pass'.
Fill both blanks to classify salary as 'Low' if less than 3000, 'Medium' if between 3000 and 7000, else 'High'.
SELECT employee, salary, CASE WHEN salary [1] 3000 THEN 'Low' WHEN salary [2] 7000 THEN 'Medium' ELSE 'High' END AS salary_level FROM employees;
The first condition checks if salary is less than 3000 for 'Low'. The second checks if salary is less than or equal to 7000 for 'Medium'. Otherwise, it's 'High'.
Fill both blanks to classify temperature as 'Cold' below 10, 'Warm' between 10 and 25, and 'Hot' above 25.
SELECT city, temperature, CASE WHEN temperature [1] 10 THEN 'Cold' WHEN temperature [2] 25 THEN 'Warm' ELSE 'Hot' END AS temp_label FROM weather;
The first condition checks if temperature is less than 10 for 'Cold'. The second checks if temperature is less than or equal to 25 for 'Warm'. Otherwise, it's 'Hot'.