Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Conditional Bonus Calculation

Pay a 10% bonus to employees in department 1 and 5% to everyone else, but 0 for employees whose name starts with 'M'. Return name and bonus rounded to two decimals, ordered by name.

Table schema

Employees(id INT PRIMARY KEY, name VARCHAR(50), department_id INT, salary INT)

Sample data

id | name | department_id | salary
1 | Alice | 1 | 1000
2 | Mark | 1 | 2000
3 | Zed | 2 | 1000

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.