[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 ...
随机推荐
- Codeforces 1108D - Diverse Garland - [简单DP]
题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per te ...
- [No0000149]ReSharper操作指南6/16-编码协助之其他协助
语法高亮 ReSharper扩展了默认Visual Studio的符号高亮显示.此外,它还会使用可配置的颜色突出显示字段,局部变量,类型和其他标识符.例如,ReSharper语法突出显示允许您轻松区分 ...
- CentOS7初始化mysql库报错
在centos7上安装mysql数据库,进行数据库初始化工作时,报错缺少data::dumper库文件,如下: 解决办法:安装autoconf库后重新初始化即可解决. yum-y install au ...
- dos基本指令
目录操作 dir 操作磁盘文件目录 md / mkdir <folder name> 创建子目录make directory cd 改变当前工作目录,返回上一级 cd .. rd 删 ...
- Hibernate的配置文件,hibernate.cfg.xml
单纯的只针对持久层框架 Hibernate 配置文件的一些总结 一.Hibernate底层原理 1. Hibernate保存原理 目的:把domain对象保存到数据库的表,形成一条记录. sql: i ...
- [archlinux][daily] 自建DNS服务器 / 建立本地DNS cache / 使用dnsmasq加速上网
新公司,上网超慢,DNS竟然是远程地址,终于找到机会学习一下dnsmasq了. update@20170516: 上网慢是因为分给我的IP有限流策略,其实远端DNS并不会造成感受上的上网慢. 参考:h ...
- Appium入门(9)—— Appium API
摘自:http://www.testclass.net/appium/appium-base-api-01/ 1.安装: installApp() driver.installApp("d: ...
- Flask需要登录权限的装饰器写法
def wapper(func): def inner(*args,**kwargs): if not request.cookies.get("username"): retur ...
- JdbcTemplate中向in语句传参
spring jdbc包提供了JdbcTemplate和它的两个兄弟SimpleJdbcTemplate和NamedParameterJdbcTemplate,我们先从JdbcTemplate入手, ...
- WCF访问超时:HTTP 请求已超过xx:yy分配的超时。为此操作分配的时间可能是较长超时的一部分。
在服务端设置时间长些 <client> <endpoint address="http://43.98.49.189:5700/UPJWCFServcie.svc" ...