LeetCode Answer
-still going on, will update
Sep 28, 2023
577. employee bonus answer
CREATE TABLE EMPLOYEE (
empId int PRIMARY KEY,
name VARCHAR(50),
supervisor int,
salary int
);
INSERT INTO EMPLOYEE (empId,name,supervisor,salary)
VALUES (1, 'John', 3, 1000),
(2, 'Dan', 3, 2000),
(3, 'Brad', NULL, 4000),
(4, 'Thomas', 3, 4000);
CREATE TABLE bonus (
empId INTEGER PRIMARY KEY,
bonus INTEGER
);
INSERT INTO bonus VALUES (2, 500);
INSERT INTO bonus VALUES (4, 2000);
SELECT * FROM EMPLOYEE;
SELECT * FROM bonus;
--the answer
SELECT name, bonus
FROM EMPLOYEE
LEFT JOIN bonus
ON EMPLOYEE.empId = bonus.empId
WHERE bonus.bonus < 1000
or bonus.bonus is nullGet Fijaya Bimasakti’s stories in your inbox
Join Medium for free to get updates from this writer.
Reference:







