[LeetCode]577. Employee Bonus 员工奖金
Posted 轻风舞动
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode]577. Employee Bonus 员工奖金相关的知识,希望对你有一定的参考价值。
Select all employee‘s name and bonus whose bonus is < 1000.
Table:Employee
+-------+--------+-----------+--------+ | empId | name | supervisor| salary | +-------+--------+-----------+--------+ | 1 | John | 3 | 1000 | | 2 | Dan | 3 | 2000 | | 3 | Brad | null | 4000 | | 4 | Thomas | 3 | 4000 | +-------+--------+-----------+--------+ empId is the primary key column for this table.
Table: Bonus
+-------+-------+ | empId | bonus | +-------+-------+ | 2 | 500 | | 4 | 2000 | +-------+-------+ empId is the primary key column for this table.
Example ouput:
+-------+-------+ | name | bonus | +-------+-------+ | John | null | | Dan | 500 | | Brad | null | +-------+-------+
选出所有奖金<1000元的雇员姓名及奖金数额
解法1:
# Write your mysql query statement below SELECT name, bonus FROM Employee LEFT JOIN Bonus USING (empId) WHERE IFNULL(bonus, 0) < 1000
解法2:
select name, bonus from Employee e left join Bonus b on e.empId = b.empId where bonus < 1000 or bonus is null
以上是关于[LeetCode]577. Employee Bonus 员工奖金的主要内容,如果未能解决你的问题,请参考以下文章
sql http://dbpatterns.com/documents/577e3a6f1514b4252236e36c/export/sqlite
[LeetCode&Python] Problem 690. Employee Importance
[leetcode-690-Employee Importance]
LeetCode - 690. Employee Importance