[SQL]LeetCode577.员工奖金 | Employee Bonus

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤微信公众号:山青咏芝(shanqingyongzhi)
➤博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/
➤GitHub地址:https://github.com/strengthen/LeetCode
➤原文地址:http://www.javashuo.com/article/p-nlnahjns-me.html 
➤若是连接不是山青咏芝的博客园地址,则多是爬取做者的文章。
➤原文已修改更新!强烈建议点击原文地址阅读!支持做者!支持原创!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★html

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

Table:Employeegithub

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

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

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

Table:Employeecode

+-------+--------+-----------+--------+
| empId |  name  | supervisor| salary |
+-------+--------+-----------+--------+
|   1   | John   |  3        | 1000   |
|   2   | Dan    |  3        | 2000   |
|   3   | Brad   |  null     | 4000   |
|   4   | Thomas |  3        | 4000   |
+-------+--------+-----------+--------+
 此表的主键列为empId。

Table: Bonushtm

+-------+-------+
| empId | bonus |
+-------+-------+
| 2     | 500   |
| 4     | 2000  |
+-------+-------+
 此表的主键列为empId。

Example ouput:blog

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

1 SELECT
2     Employee.name, Bonus.bonus
3 FROM
4     Employee
5         LEFT OUTER JOIN
6     Bonus ON Employee.empid = Bonus.empid
7 ;

 1 # Write your MySQL query statement below
 2 
 3 SELECT
 4     Employee.name, Bonus.bonus
 5 FROM
 6     Employee
 7         LEFT JOIN
 8     Bonus ON Employee.empid = Bonus.empid
 9 WHERE
10     bonus < 1000 OR bonus IS NULL
11 ;
相关文章
相关标签/搜索