Complete the code to select the grade based on score using CASE WHEN.
SELECT score, CASE WHEN score >= 90 THEN 'A' ELSE 'F' END AS grade FROM exams WHERE score [1] 80;
The condition >= checks if the score is at least 80 to filter the rows.
Complete the code to assign 'Pass' or 'Fail' based on marks using CASE WHEN.
SELECT student_id, marks, CASE WHEN marks [1] 50 THEN 'Pass' ELSE 'Fail' END AS result FROM results;
The operator >= checks if marks are 50 or more to assign 'Pass'.
Fix the error in the CASE WHEN expression to categorize age groups.
SELECT name, age, CASE WHEN age [1] 18 THEN 'Minor' ELSE 'Adult' END AS age_group FROM people;
The correct operator to check if age is 18 or less is <=. The option => is invalid syntax in SQL.
Fill both blanks to classify salary levels using CASE WHEN.
SELECT employee_id, salary, CASE WHEN salary [1] 50000 THEN 'Low' WHEN salary [2] 100000 THEN 'High' ELSE 'Medium' END AS salary_level FROM employees;
The first condition checks if salary is less than 50000 for 'Low'. The second checks if salary is 100000 or more for 'High'. Salaries in between are 'Medium'.
Fill all three blanks to create a CASE WHEN expression that labels product stock status.
SELECT product_name, stock, CASE WHEN stock [1] 0 THEN 'Out of stock' WHEN stock [2] 50 THEN 'Low stock' ELSE 'In stock' END AS stock_status FROM inventory WHERE stock [3] 0;
The first blank checks if stock equals 0 for 'Out of stock'. The second checks if stock is 50 or less for 'Low stock'. The WHERE clause filters products with stock greater than or equal to 0.