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 ...
随机推荐
- 从MYSQL数据库查出指定格式的日期
1.用SQL语言控制: 格式如下: select DATE_FORMAT(t.startTime,"%Y-%m-%d %H:%i") AS startTime, DATE_FORM ...
- Widows与linux关于隐形文件和非隐形文件の对比
Widows与linux关于隐形文件和非隐形文件の对比 对于windows来说 ,它本身有一些隐藏文件,为了防止一些菜鸟不小心把电脑的主要文件删除,还有就是里面存放一些你不知道的后门. 对此我们一些同 ...
- 细谈select函数(C语言)
Select在Socket编程中还是比较重要的,可是对于初学Socket的人来说都不太爱用Select写程序,他们只是习惯写诸如connect.accept.recv或recvfrom这样的阻塞程序( ...
- idea 多模块引用
roma-server 引用common-utils的类,所以在roma-server 的pom中配置 <dependency> <groupId>org.springfram ...
- css 常用苹方字体
// 苹方-简 常规体 font-family: PingFangSC-Regular, sans-serif; // 苹方-简 极细体 font-family: PingFangSC-Ultrali ...
- Enterprise Architect13 : 去掉UML图页面右侧那一道竖线
我们在使用Enterprise Architect 中,画用例图,时序图时,页面右侧有一条竖线,见下图: 如果页面元素太多,会超出竖线的范围,显得很不协调. 如果像去掉竖线,只需选择主菜单的Layou ...
- 【比赛】洛谷夏令营NOIP模拟赛
Day1 第一题 水题 第二题 题意:一个n*m的字符矩阵从左上到右下,经过字符形成回文串的路径数.n≤500 回文串,考虑两段往中间DP. f[k][x][y]表示走了k步,左上点横坐标为x,右下点 ...
- Python switch-case语句的实现 -- 字典模拟实现
static void print_asru_status(int status, char *label) { char *msg = NULL; switch (status) { : msg = ...
- 空间数据库系列一:geomesa&sparksql 分析环境搭建
geomesa sparksql 分析环境搭建 1.安装hbase-1.3.2.1 standlone版本,作为geomesa的store a.修改配置文件:hbase-1.3.2.1/conf/hb ...
- Webmin LFD to LFI
Webmin < 1.290 / Usermin < 1.220 - Arbitrary File Disclosure (Perl) https://www.exploit-db.com ...