181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.
+----+-------+--------+-----------+
| Id | Name | Salary | ManagerId |
+----+-------+--------+-----------+
| 1 | Joe | 70000 | 3 |
| 2 | Henry | 80000 | 4 |
| 3 | Sam | 60000 | NULL |
| 4 | Max | 90000 | NULL |
+----+-------+--------+-----------+
Given the Employee table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.
+----------+
| Employee |
+----------+
| Joe |
+----------+ 自连接
找出比其上司挣得更多的员工 MySQL(1686ms):
SELECT e1.Name AS Employee
FROM Employee AS e1 , Employee AS e2
WHERE e1.ManagerId = e2.Id
AND e1.Salary > e2.Salary ;
181. Employees Earning More Than Their Managers的更多相关文章
- Leetcode 181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- 【SQL】181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- leetcode 181 Employees Earning More Than Their Managers 不会分析的数据库复杂度
https://leetcode.com/problems/employees-earning-more-than-their-managers/description/ 老师上课没分析这些的复杂度, ...
- LeetCode 181. Employees Earning More Than Their Managers (超过经理收入的员工)
题目标签: 题目给了我们一个 员工表,包括经理.员工会有经理的id. 这里可以重复 利用两次 表格,表格a, 表格b,当a 员工的经理id 等于 b员工时候,在从中找到员工工资大于经理的.具体看co ...
- [LeetCode] Employees Earning More Than Their Managers 员工挣得比经理多
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- LeeCode(Database)-Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- [SQL]LeetCode181. 超过经理收入的员工 | Employees Earning More Than Their Managers
SQL架构 Create table If Not Exists Employee (Id ), Salary int, ManagerId int) Truncate table Employee ...
- [LeetCode] 181. Employees Earning More Than Their Managers_Easy tag: SQL
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- LeetCode - Employees Earning More Than Their Managers
Description: The Employee table holds all employees including their managers. Every employee has an ...
随机推荐
- POJ2155 树状数组
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 26650 Accepted: 9825 Descripti ...
- linux内核的配置
以2.6.35.7版本的内核为例 总结:.config决定了Make时的条件编译与连接..config文件由两次配置第一次make XX_defconfig 第二次menuconfig. 1.分析源码 ...
- [Luogu 3701] 「伪模板」主席树
[Luogu 3701] 「伪模板」主席树 这是一道网络流,不是主席树,不是什么数据结构,而是网络流. 题目背景及描述都非常的暴力,以至于 Capella 在做此题的过程中不禁感到生命流逝. S 向 ...
- 元类编程-- metaclass
#类也是对象,type创建类的类 def create_class(name): if name == "user": class User: def __str__(self): ...
- 安装magento配置完数据库后出现: PHP Extensions "0" must be loaded. 解决方案
打开magento目录下的该文件: app/code/core/Mage/Install/etc/config.xml 将下面该段修改: <mysql4> <type>pdo_ ...
- bzoj 2165 DP
首先如果不考虑数据范围的话,因为每一层都是等效的,所以我们可以用w[i][j][k]来表示在某一层的j位置,称作i次电梯到k位置,最多上升多少层,那么我们可以比较容易的写出转移,因为m十分大,i可能与 ...
- Python eval 函数说明
eval(str [,globals [,locals ]]) -- 函数将字符串str当成有效Python表达式来求值,并返回计算结果. 例 : eval('3+4') ==> ...
- B题 hdu 1407 测试你是否和LTC水平一样高
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1407 测试你是否和LTC水平一样高 Time Limit: 2000/1000 MS (Java/Ot ...
- Xmind 8 update5 破解
Step 1. Download XMind Step 2. Run XMind at least once after installation, xmind will init the confi ...
- gnu app url[web][5星]
http://www.gnu.org/software/software.zh-cn.html http://linux.chinaunix.net/news/2010/12/07/1175310.s ...