[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 ...
随机推荐
- 从入门到自闭之python三大器--装饰器
开放封闭原则:在不修改源代码及调用方式,对功能进行额外添加就是开放封闭原则 开放:对代码的扩展进行开发 封闭:修改源代码 装饰(额外功能) 器:工具(函数) 普通版: # print(time.tim ...
- java判断一个单向链表是否有环路
今天刷LeetCode刷到一道这样的题,详情参见(https://leetcode-cn.com/problems/linked-list-cycle/) ADT: class ListNode { ...
- node.js--使用Express中app.use()分模块开发
app.use(path,callback)中的callback既可以是router对象又可以是函数:将一个URL路径与一个函数绑定,第一个参数为访问的路径,如果第一参数为空,则表示任何路径都触发这个 ...
- 基于Spring Cloud 几行配置完成单点登录开发
单点登录概念 单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一.SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统. ...
- centos7 mysql 各种报错
1.重置root密码 vi /etc/my.cnf 添加skip-grant-tables service mysqld restart 2.mysql 登录 报错1 Unknown system v ...
- 使用 gitolite 管理配置 git 库的权限
问题:每次创建git库都需要在gitolite的配置文件中添加git库的配置信息,为了方便管理git库,不在重复提交,所以修改gitolite的配置管理文件. 环境:ubuntu16.04 安装git ...
- 6U VPX 高性能计算存储板卡
基于6U VPX的 XC7VX690T+C6678的双FMC接口雷达通信处理板 一.板卡概述 高性能VPX信号处理板基于标准6U VPX架构,提供两个标准FMC插槽,适用于电子对抗或雷达信号等领域 ...
- 在VMware Vcenter添加一块网卡后,启动虚机找不到网卡,发现有一个ens38(redhat7.5)
添加一块网卡后,启动虚机找不到网卡,发现有一个ens38 问题:新建虚拟机设置为一块网卡,时候在Vcenter再添加一块网卡,这个问题相信很多网友都见过,今天就来总结一下添加过程中的问题. 由于有以前 ...
- CentOS7 minimal安装初始化配置
个人喜好最小化安装系统,需要配置的如下信息 1.更改网络配置为固定ip #vi /etc/sysconfig/network-scripts/ifcfg-eth0BOOTPROTO="sta ...
- 牛客练习赛26 D xor序列 (线性基)
链接:https://ac.nowcoder.com/acm/contest/180/D 来源:牛客网 xor序列 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他 ...