special-bonus.sql (355B)
1 --Calculate the employee bonuses where it is 0 if they are either even or have an M at the start of their name 2 --otherwise it is their salary. 3 SELECT Employees.employee_id, 4 CASE 5 WHEN Employees.employee_id % 2 = 1 AND SUBSTRING(Employees.name , 1, 1) != 'M' THEN Employees.salary 6 ELSE 0 7 END 8 AS bonus 9 FROM Employees 10 ORDER BY Employees.employee_id