Skip to content

Commit d04480f

Browse files
committed
task: #1873
1 parent 52d4439 commit d04480f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ Useful for preparing for technical interviews and improving your SQL skills.
146146
- [1741. Find Total Time Spent by Each Employee](./leetcode/easy/1741.%20Find%20Total%20Time%20Spent%20by%20Each%20Employee.sql)
147147
- [1789. Primary Department for Each Employee](./leetcode/easy/1789.%20Primary%20Department%20for%20Each%20Employee.sql)
148148
- [1795. Rearrange Products Table](./leetcode/easy/1795.%20Rearrange%20Products%20Table.sql)
149+
- [1873. Calculate Special Bonus](./leetcode/easy/1873.%20Calculate%20Special%20Bonus.sql)
149150
- [1890. The Latest Login in 2020](./leetcode/easy/1890.%20The%20Latest%20Login%20in%202020.sql)
150151
- [1965. Employees With Missing Information](./leetcode/easy/1965.%20Employees%20With%20Missing%20Information.sql)
151152
- [1978. Employees Whose Manager Left the Company](./leetcode/easy/1978.%20Employees%20Whose%20Manager%20Left%20the%20Company.sql)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Question 1873. Calculate Special Bonus
3+
Link: https://leetcode.com/problems/calculate-special-bonus/description/?envType=problem-list-v2&envId=database
4+
5+
Table: Employees
6+
7+
+-------------+---------+
8+
| Column Name | Type |
9+
+-------------+---------+
10+
| employee_id | int |
11+
| name | varchar |
12+
| salary | int |
13+
+-------------+---------+
14+
employee_id is the primary key (column with unique values) for this table.
15+
Each row of this table indicates the employee ID, employee name, and salary.
16+
17+
18+
Write a solution to calculate the bonus of each employee. The bonus of an employee is 100% of their salary if the ID of the employee is an odd number and the employee's name does not start with the character 'M'. The bonus of an employee is 0 otherwise.
19+
20+
Return the result table ordered by employee_id.
21+
*/
22+
23+
SELECT
24+
employee_id,
25+
(CASE
26+
WHEN employee_id % 2 = 0 OR LEFT(name, 1) = 'M'
27+
THEN 0
28+
ELSE salary
29+
END) AS bonus
30+
FROM Employees
31+
ORDER BY employee_id ASC

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy