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

  

All LeetCode Questions List 题目汇总

[LeetCode]577. Employee Bonus 员工奖金的更多相关文章

  1. 【leetcode_easy_$】577. Employee Bonus

    problem 577. Employee Bonus 参考 1. Leetcode_easy_$_577. Employee Bonus; 2. https://www.cnblogs.com/li ...

  2. [LeetCode] 577. Employee Bonus_Easy tag: SQL

    Select all employee's name and bonus whose bonus is < 1000. Table:Employee +-------+--------+---- ...

  3. 解题报告 - 577. Employee Bonus

    Select all employee's name and bonus whose bonus is < 1000. Table:Employee +-------+--------+---- ...

  4. [LeetCode]690. Employee Importance员工重要信息

    哈希表存id和员工数据结构 递归获取信息 public int getImportance(List<Employee> employees, int id) { Map<Integ ...

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

    Select all employee's name and bonus whose bonus is < 1000. Table:Employee +-------+--------+---- ...

  6. [LeetCode] Employee Importance 员工重要度

    You are given a data structure of employee information, which includes the employee's unique id, his ...

  7. LeetCode 690. Employee Importance (职员的重要值)

    You are given a data structure of employee information, which includes the employee's unique id, his ...

  8. Leetcode690.Employee Importance员工的重要性

    给定一个保存员工信息的数据结构,它包含了员工唯一的id,重要度 和 直系下属的id. 比如,员工1是员工2的领导,员工2是员工3的领导.他们相应的重要度为15, 10, 5.那么员工1的数据结构是[1 ...

  9. LeetCode - 690. Employee Importance

    You are given a data structure of employee information, which includes the employee's unique id, his ...

随机推荐

  1. ThinkPHP模板之二

    模板布局及变量比较,循环. controller <?php /** * Created by PhpStorm. * User: Sahara * Date: 2019/6/23 * Time ...

  2. django migrate报错:1005 - Can't create table xxx (errno: 150 "Foreign key constraint is incorrectly formed")

    自从mysql升级,以及使用mariaDB以来,很多不曾更新django中model的外键, 今天,按以前的思路写完外键之后, migrate命令报错: 1005 - Can't create tab ...

  3. Zabbix导入MySQL数据库报错ERROR 1046 (3D000) at line 1: No database selected

    使用如下命令导入Zabbix数据库时报错 解决办法: 1.先把原始的数据库压缩包备份 cd /usr/share/doc/zabbix-server-mysql-4.0.7/ cp create.sq ...

  4. Python应用之-file 方法

    #!/usr/bin/env python # *_* coding=utf-8 *_* """ desc: 文件方法 ######################### ...

  5. 神奇的 Object.defineProperty 解释说明

    原文 : https://segmentfault.com/a/1190000004346467?utm_source=tuicool&utm_medium=referral 这个方法了不起啊 ...

  6. Switch ……case语句

    Switch(变量){ case 1: 如果变量和1的值相同,执行该处代码 break; case 2: 如果变量和2的值相同,执行该处代码 break; case 3: 如果变量和3的值相同,执行该 ...

  7. 18-ESP8266 SDK开发基础入门篇--TCP 服务器 RTOS版,串口透传,TCP客户端控制LED

    https://www.cnblogs.com/yangfengwu/p/11112015.html 先规定一下协议 aa 55 02 01 F1 4C 控制LED点亮  F1 4C为CRC高位和低位 ...

  8. PhpStorm 设置自动FTP同步文件

    1.添加一个FTP服务器 ① 首先在这里打开添加FTP的页面,步骤,工具栏 -> Tools -> Deployment -> Configuration .     ②添加服务器  ...

  9. ICEM-非结构化网格中创建无厚度的面

    原版视频下载地址:https://pan.baidu.com/s/1pLazbOf 密码: 4pii

  10. Linux 权限规划ACL

    什么是ACL ACL是Access Control List的缩写,主要目的是提供传统的owner.group.others的read.write.execute权限之外的具体权限设置 ACL可以针对 ...