超过经理收入的员工 表的自JOIN
https://leetcode-cn.com/problems/employees-earning-more-than-their-managers/description/
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 |
+----------+ SELECT e.Name AS Employee FROM Employee e LEFT JOIN Employee eb ON e.ManagerId=eb.Id WHERE e.ManagerId IS NOT NULL AND e.Salary>eb.Salary;
超过经理收入的员工 表的自JOIN的更多相关文章
- 181. 超过经理收入的员工 + join + MySql
181. 超过经理收入的员工 LeetCode_MySql_181 题目描述 方法一:笛卡尔积 # Write your MySQL query statement below select e1.N ...
- LeetCode:181.超过经理收入的员工
题目链接:https://leetcode-cn.com/problems/employees-earning-more-than-their-managers/ 题目 Employee 表包含所有员 ...
- sql 181. 超过经理收入的员工
Employee 表包含所有员工,他们的经理也属于员工.每个员工都有一个 Id,此外还有一列对应员工的经理的 Id. +----+-------+--------+-----------+| Id | ...
- [LeetCode] 181.超过经理收入的员工
Employee表包含所有员工,他们的经理也属于员工.每个员工都有一个 Id,此外还有一列对应员工的经理的 Id. +----+-------+--------+-----------+ | Id | ...
- LeetCode 181. Employees Earning More Than Their Managers (超过经理收入的员工)
题目标签: 题目给了我们一个 员工表,包括经理.员工会有经理的id. 这里可以重复 利用两次 表格,表格a, 表格b,当a 员工的经理id 等于 b员工时候,在从中找到员工工资大于经理的.具体看co ...
- [SQL]LeetCode181. 超过经理收入的员工 | Employees Earning More Than Their Managers
SQL架构 Create table If Not Exists Employee (Id ), Salary int, ManagerId int) Truncate table Employee ...
- 自关联映射:一个表自己关联自己,此时从同一个表中查询,通过起别名将一张表变成两张表,使用join语句。
实例1:id自关联. 隐式内连接: 实例二:编写一个 SQL 查询,来查找与之前(昨天的)日期相比温度更高的所有日期的 id .返回结果 不要求顺序 . 查询结果格式如下例: Weather +--- ...
- olacle数据库员工表的创建,及插入数据,添加约束,删除列,查询数据的sql语句
---删除原有的员工表drop TABLE employee;---创建员工表CREATE TABLE employee ( empno NUMBER(4) NOT NULL, ...
- java数据库 JDBC操作MySQL数据库常用API 部门表和员工表 创建表 添加数据 查询数据
package com.swift.department; import java.sql.Connection; import java.sql.PreparedStatement; import ...
随机推荐
- nginx启动、重启、关闭、升级
一.启动 cd usr/local/nginx/sbin ./nginx 二.重启 更改配置重启nginx kill -HUP 主进程号或进程号文件路径 或者使用 cd /usr/local/ngin ...
- python013 Python3 条件控制
Python3 条件控制Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块.可以通过下图来简单了解条件语句的执行过程: if 语句Python中if语句的一 ...
- hrbust-1909理工门外的树,不用线段数,贪心思路~~
理工门外的树 Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 605(125 users) Total Accepted: 154(11 ...
- VIM键盘图
- codeforces #299 div 2
(总算是5题都做完了- -) 暂时做了4题,先放一下有时间做最后一题(当然如果我真的能做出的话...)(看了大神的代码总算是理解了E题,做完发现也没那么难,果然想出一个思路的过程对于我这种弱渣来说还是 ...
- 背包!背包!HDU 2602 Bone Collector + HDU 1114 Piggy-Bank + HDU 2191 512
http://acm.hdu.edu.cn/showproblem.php?pid=2602 第一题 01背包问题 http://acm.hdu.edu.cn/showproblem.php?pid= ...
- iOS React Native 环境的搭建
react native 的官网:http://reactnative.cn/docs/0.47/getting-started.html#content --iOS如何搭建mac版的环境 1.配置 ...
- 2016 ACM/ICPC 区域赛(北京) E 题 bfs
https://vjudge.net/problem/UVALive-7672 题意 输入一个五位数n 问由12345变到n的操作最少次数 不可达输出-1 有三种操作 1.交换相邻的位置 次数不 ...
- HDU 6333 莫队+组合数
Problem B. Harvest of Apples Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K ...
- codeforces 875F(基环外向树)
题意 有一个左边m个点,右边n个点的二分图(n,m<=1e5),左边每个点向右边恰好连两条权值相同的边. 求这个二分图的最优匹配 分析 对于这种二选一问题,即左边的a连向右边的b和c,权值为d, ...