[LeetCode]577. Employee Bonus 员工奖金

2021年09月15日 阅读数:1
这篇文章主要向大家介绍[LeetCode]577. Employee Bonus 员工奖金,主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。

Select all employee's name and bonus whose bonus is < 1000.html

Table:Employeesql

+-------+--------+-----------+--------+
| 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: Bonuspost

+-------+-------+
| empId | bonus |
+-------+-------+
| 2     | 500   |
| 4     | 2000  |
+-------+-------+
empId is the primary key column for this table.

Example ouput:this

+-------+-------+
| name  | bonus |
+-------+-------+
| John  | null  |
| Dan   | 500   |
| Brad  | null  |
+-------+-------+

选出全部奖金<1000元的雇员姓名及奖金数额url

解法1:code

# Write your MySQL query statement below
SELECT name, bonus 
FROM Employee LEFT JOIN Bonus USING (empId)
WHERE IFNULL(bonus, 0) < 1000  

解法2:htm

select name, bonus
from 
Employee e left join Bonus b
on e.empId = b.empId
where bonus < 1000 or bonus is null

  

 

All LeetCode Questions List 题目汇总