Complete the code to filter rows where the status is 'active'.
SELECT * FROM users WHERE status = [1];The status column is a string, so the value 'active' must be enclosed in single quotes in SQL.
Complete the code to use CASE in WHERE clause to filter users by role.
SELECT * FROM users WHERE role = CASE WHEN is_admin = 1 THEN [1] ELSE 'user' END;
The CASE expression returns a string, so 'admin' must be in quotes.
Fix the error in the CASE expression inside the WHERE clause.
SELECT * FROM orders WHERE CASE [1] WHEN 'shipped' THEN 1 ELSE 0 END = 1;
The CASE expression compares the column 'status' to the WHEN value.
Fill both blanks to filter products by price range using CASE in WHERE clause.
SELECT * FROM products WHERE price [1] CASE WHEN category = 'luxury' THEN 1000 ELSE [2] END;
The query filters products with price greater than 1000 if category is 'luxury', otherwise greater than 500.
Fill all three blanks to filter employees by department and salary using CASE in WHERE clause.
SELECT * FROM employees WHERE salary [1] CASE WHEN department = [2] THEN [3] ELSE 50000 END;
The query selects employees in HR with salary > 60000, or others with salary > 50000.