Special Bonus Logic

ASKED IN INTERVIEW
2pts
Apple

Problem Statement

Apple is rewarding employees with a special bonus. You need to calculate the bonus amount for each employee.

The bonus logic is as follows:

  • The bonus is 100% of the salary if the employee_id is an odd number AND the employee name does NOT start with the letter M.
  • Otherwise, the bonus is 0.

Write an SQL query to return the employee_id and the calculated bonus.

Rules:

  • Output columns: employee_id, bonus.
  • Results must be sorted by employee_id in ascending order.
Tests your understanding of
Logic, Strings and Conditional Aggregation

Input Tables

employees
employee_id(INTEGER)name(VARCHAR)salary(INTEGER)
2Meir3000
3Michael3800
7Addison7400
8Juan6100
9Kiki7700
departments
dept_id(INTEGER)dept_name(VARCHAR)
1Engineering
2Sales
employee_dept_mapping
employee_id(INTEGER)dept_id(INTEGER)
21
31
72
82
91

Expected Output

employee_id(INTEGER)bonus(INTEGER)
20
30
77400
80
97700

Tags

EasyASKED IN INTERVIEWLogicStringsConditional Aggregation
10-15 min
65%

Hints