[LeetCode]-DataBase-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 |
+----------+ 要求:查询出表中工资比经理高的员工姓名 查询一:
CREATE TABLE `employee` (
`id` tinyint(3) unsigned DEFAULT NULL,
`e_name` varchar(20) DEFAULT NULL,
`salary` decimal(10,2) DEFAULT NULL,
`m_id` tinyint(3) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SELECT em1.e_name
FROM(SELECT id,e_name,salary,m_id FROM employee_1 WHERE m_id IS NOT NULL) em1
INNER JOIN employee_1 em2 ON em1.m_id=em2.id
WHERE em1.salary>em2.salary
查询二:
SELECT e1.e_name
FROM employee_1 e1
INNER JOIN employee_1 e2 ON e1.m_id=e2.id
WHERE e1.salary>e2.salary
[LeetCode]-DataBase-Employees Earning More Than Their Managers的更多相关文章
- LeeCode(Database)-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
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- DataBase -- Employees Earning More Than Their Managers My Submissions Question
Question: The Employee table holds all employees including their managers. Every employee has an Id, ...
- 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 SQL:Employees Earning More Than Their Managers
# Write your MySQL query statement below SELECT a.Name FROM Employee AS a INNER JOIN Employee AS b O ...
- [LeetCode] Employees Earning More Than Their Managers 员工挣得比经理多
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 ...
- LeetCode——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 ...
随机推荐
- 2017.9.23 C组比赛总结
今天又回到了C组,感觉爽歪歪~分数终于是个三位数了,yes! 第一题,赛车.水!只用一个贪心就可以AC了. first,以速度为关键字小到大qsort一下... scond,枚举每一个赛车,看看它可以 ...
- transform(转https://blog.csdn.net/qq_24189933/article/details/79293870)
transform 前面我们一起学习了CSS3中的渐变.圆角.阴影等几个属性的使用,今天开始我们一起来学习有关于CSS3制作动画的几个属性:变形(transform).转换(transition)和动 ...
- 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 F. Islands
On the mysterious continent of Tamriel, there is a great empire founded by human. To develope the tr ...
- jumpserver-1.4.8安装步骤
1. 组件说明 Jumpserver 为管理后台, 管理员可以通过 Web 页面进行资产管理.用户管理.资产授权等操作, 用户可以通过 Web 页面进行资产登录, 文件管理等操作 koko 为 SSH ...
- eval解惑
let a = 1, b = 2, c = 3; let arr = [a, b, c]; function test(p1, p2, p3) { console.log(`${p1} ~ ${p2} ...
- java压缩文件中文名乱码问题
import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; 改为 import org.apache.tools.zip. ...
- iOS-NSLog发布时取消打印日志
1 选择工程的Target -> Build Settings -> Preprocessor Macros. 如图,默认 Debug项,是“DEBUG=1”. 2 在程序中设置全局宏定义 ...
- 使用redis客户端连接windows和linux下的redis并解决无法连接redis的问题
搭建环境:linux是centos7.4(请注意centos7以下版本的防火墙跟centos7以上的不同,使用redis客户端连接redis时会有区别,建议使用centos7以上版本) 一.下载red ...
- Linux学习--第十三天--日志、系统运行级别、grub加密
日志 rsyslogd取代了syslogd. /var/log/cron #定时任务相关日志 /var/log/cups #打印信息相关日志 /var/log/dmesg #开机内核自检相关日志,dm ...
- 一、Core授权-2 之.net core 基于Jwt实现Token令牌
一.Startup类配置 ConfigureServices中 //添加jwt验证: services.AddAuthentication(JwtBearerDefaults.Authenticati ...