Complete the code to create a new column status that shows 'active' if is_active is true, otherwise 'inactive'.
select user_id, case when is_active = [1] then 'active' else 'inactive' end as status from users
The case when checks if is_active is true to assign 'active'.
Complete the code to assign category as 'high' if score is greater than 80, else 'low'.
select user_id, case when score [1] 80 then 'high' else 'low' end as category from scores
The condition checks if score is greater than 80 to assign 'high'.
Fix the error in the code to correctly assign risk_level based on age: 'senior' if age >= 65, else 'adult'.
select user_id, case when age [1] 65 then 'senior' else 'adult' end as risk_level from demographics
The condition must check if age is greater than or equal to 65 to assign 'senior'.
Fill both blanks to create a column discount that is 0.2 if purchase_amount is greater than 100, else 0.
select customer_id, case when purchase_amount [1] 100 then [2] else 0 end as discount from sales
The code checks if purchase_amount is greater than 100 to assign a 0.2 discount.
Fill all three blanks to create a column grade that is 'A' if score >= 90, 'B' if score >= 80, else 'C'.
select student_id, case when score [1] 90 then 'A' when score [2] 80 then 'B' else [3] end as grade from exams
Both conditions use '>=' to include the boundary scores, and else assigns 'C'.