[LeetCode] 577. Employee Bonus_Easy tag: SQL
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 |
+-------+-------+ Code
SELECT e.name, b.bonus FROM Employee as e LEFT JOIN Bonus as b ON e.empId = b.empId WHERE b.bonus IS NULL or b.bonus < 1000
# 不能直接用JOIN, 相当于inner join, 如果bonus没有的, 那么就没有了, 所以上面的例子只会输出Dan, 500 这一栏而已.
[LeetCode] 577. Employee Bonus_Easy tag: SQL的更多相关文章
- [LeetCode]577. Employee Bonus 员工奖金
Select all employee's name and bonus whose bonus is < 1000. Table:Employee +-------+--------+---- ...
- [LeetCode] 182. Duplicate Emails_Easy tag: SQL
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- [LeetCode] 197. Rising Temperature_Easy tag: SQL
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- [LeetCode] 595. Big Countries_Easy tag: SQL
There is a table World +-----------------+------------+------------+--------------+---------------+ ...
- [LeetCode] 690. Employee Importance_Easy tag: BFS
You are given a data structure of employee information, which includes the employee's unique id, his ...
- [LeetCode] 610. Triangle Judgement_Easy tag: SQL
A pupil Tim gets homework to identify whether three line segments could possibly form a triangle. Ho ...
- [LeetCode] 607. Sales Person_Easy tag: SQL
Description Given three tables: salesperson, company, orders.Output all the names in the table sales ...
- [LeetCode] 627. Swap Salary_Easy tag: SQL
Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m v ...
- [LeetCode] 130. Surrounded Regions_Medium tag: DFS/BFS
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A reg ...
随机推荐
- ThinkPHP框架 祖辈分的理解 【儿子 FenyeController】继承了【父亲 FuController】继承了【祖辈 Controller】的
注:系统自带的Controller方法代表的是祖辈 FuController控制器是自定义的,代表父亲... FenyeController控制器就代表着儿子 [儿子 FenyeController] ...
- C# 单元测试能过,但Web项目就报错!
第一印象肯定是两个项目中各有不同的地方 背景: 公司项目采用IBatic+Castle实现 排查过程: 1.sqlmap文件是否一至,并且读取位置也要正确 2.dao.config文件要一至,读取位置 ...
- sql优化的方法
参考:https://blog.csdn.net/jie_liang/article/details/77340905 11.不要写一些没有意义的查询,如需要生成一个空表结构: select col1 ...
- 关于Linux一些问题和答案
1.怎样切换输入法? 2.怎样安装KDE? $sudo apt-get install kubuntu-desktop 3.安装KDE以后,怎样切回到默认的gnome? 注销,返回到登录界面,在“登录 ...
- nethogs 查看 Linux 进程的网络使用
有时候我们客户会发现服务器或 VPS 网络慢,进一步发现大量带宽被占用,一些客户到这里为止就不知道怎么办了.有什么简单办法能找出哪个程序(或者进程)占用了带宽呢?Linux 监控流量的小工具不少,如 ...
- OpenGL开发学习指南二(glfw+glad)
版权声明:本文为博主原创文章,未经博主允许不得转载.blog.liujunliang.com.cn https://blog.csdn.net/qq_33747722/article/details/ ...
- .net WebService的使用
1. WebService可单独作为一个网站,不限平台的被调用. 2. 打开VS,选择新建 3. [WebMethod] 方法上面有这个说明,则表示此方法可被外部调用. 我们添加4个方法:加.减.乘. ...
- [qemu][kvm] 在一个vmware虚拟机里安装qemu-kvm虚拟机
说起来这个需求,简直是傻傻的.但却实实在在的摆在我的面前.... VM无外乎就是为了模拟场景:我现在要的场景就是一台很多个core的linux主机.但是我只有一个装了windows的笔记本.上边有一个 ...
- navicat连接oracle失败
正常是成功的,失败的话,就是oci.dll的问题 在这边下载: https://www.oracle.com/technetwork/topics/winsoft-085727.html 然后找到对应 ...
- django--验证码功能实现
首先建立验证码的视图函数1需要安装pillow库 #导入绘图库 from PIL import ImageDraw #导入绘图字体库 from PIL import ImageFont #导入图片库 ...