Complete the code to order the results by the CASE expression.
SELECT name, score FROM players ORDER BY CASE WHEN score > 50 THEN [1] ELSE score END;
The CASE expression returns 0 when score > 50, so ordering by this puts those players first.
Complete the code to order by priority using CASE, putting 'urgent' first.
SELECT task, priority FROM tasks ORDER BY CASE priority WHEN 'urgent' THEN [1] ELSE 2 END;
Assigning 1 to 'urgent' tasks makes them appear before others when ordered ascending.
Fix the error in the CASE expression inside ORDER BY to sort by status.
SELECT id, status FROM orders ORDER BY CASE status WHEN 'shipped' THEN [1] WHEN 'pending' THEN 2 ELSE 3 END;
The CASE expression must return a number, not a string, to order correctly.
Fill both blanks to order by category priority and then by name alphabetically.
SELECT product, category FROM inventory ORDER BY CASE category WHEN 'electronics' THEN [1] WHEN 'furniture' THEN [2] ELSE 3 END, name;
Assigning 1 to 'electronics' and 2 to 'furniture' orders electronics first, then furniture, then others.
Fill all three blanks to order employees by role priority, then by last name ascending.
SELECT employee_id, role, last_name FROM employees ORDER BY CASE role WHEN 'manager' THEN [1] WHEN 'developer' THEN [2] ELSE [3] END, last_name;
Assigning 0 to 'manager' makes them highest priority, 2 to 'developer', and 3 to others.