From 189fca6c65b460c76b9a572344af2701313dd8a8 Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Sun, 29 Jun 2025 12:17:23 +0300 Subject: [PATCH] task: #577 --- README.md | 1 + ...oyees Earning More Than Their Managers.sql | 2 +- leetcode/easy/577. Employee Bonus.sql | 46 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 leetcode/easy/577. Employee Bonus.sql diff --git a/README.md b/README.md index a8397b1..89e622a 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Have a good contributing! - [182. Duplicate Emails](./leetcode/easy/182.%20Duplicate%20Emails.sql) - [183. Customers Who Never Order](./leetcode/easy/183.%20Customers%20Who%20Never%20Order.sql) - [511. Game Play Analysis 1](./leetcode/easy/511.%20Game%20Play%20Analysis%201.sql) + - [577. Employee Bonus](./leetcode/easy/577.%20Employee%20Bonus.sql) - [595. Big Countries](./leetcode/easy/595.%20Big%20Countries.sql) ## License diff --git a/leetcode/easy/181. Employees Earning More Than Their Managers.sql b/leetcode/easy/181. Employees Earning More Than Their Managers.sql index 94025fd..ecc29c6 100644 --- a/leetcode/easy/181. Employees Earning More Than Their Managers.sql +++ b/leetcode/easy/181. Employees Earning More Than Their Managers.sql @@ -26,7 +26,7 @@ Return the result table in any order. SELECT t1.name AS Employee FROM Employee AS t1 -JOIN +LEFT JOIN Employee AS t2 ON t1.managerId = t2.id WHERE t1.salary > t2.salary diff --git a/leetcode/easy/577. Employee Bonus.sql b/leetcode/easy/577. Employee Bonus.sql new file mode 100644 index 0000000..e25f1a4 --- /dev/null +++ b/leetcode/easy/577. Employee Bonus.sql @@ -0,0 +1,46 @@ +/* +Question 577. Employee Bonus +Link: https://leetcode.com/problems/employee-bonus/description/ + +Table: Employee + ++-------------+---------+ +| Column Name | Type | ++-------------+---------+ +| empId | int | +| name | varchar | +| supervisor | int | +| salary | int | ++-------------+---------+ +empId is the column with unique values for this table. +Each row of this table indicates the name and the ID +of an employee in addition to their salary and the id of their manager. + + +Table: Bonus + ++-------------+------+ +| Column Name | Type | ++-------------+------+ +| empId | int | +| bonus | int | ++-------------+------+ +empId is the column of unique values for this table. +empId is a foreign key (reference column) to empId from the Employee table. +Each row of this table contains the id of an employee and their respective bonus. + + +Write a solution to report the name and +bonus amount of each employee with a bonus less than 1000. + +Return the result table in any order. +*/ + +SELECT + Employee.name, + Bonus.bonus +FROM Employee +LEFT JOIN + Bonus + ON Employee.empId = Bonus.empId +WHERE Bonus.bonus < 1000 OR Bonus.bonus IS NULL