DDSA Solutions

1873. Calculate Special Bonus

Advertisement

About this solution

Calculate Special Bonus is a unknown-difficulty LeetCode problem covering the Database pattern. The MySQL solution below uses an idiomatic approach that is clean, readable, and directly submittable on LeetCode. Study the logic carefully — recognising the underlying pattern is the key skill that transfers to similar problems in interviews.

Key Techniques

1873.sql
MySQL
/* Write your T-SQL query statement below */
SELECT
  employee_id,
  CASE WHEN employee_id % 2 = 1 AND LEFT(name, 1) != 'M' THEN  salary ELSE  0 END AS bonus
FROM Employees
ORDER BY 1;
Advertisement
Was this solution helpful?