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 |
+----------+
 # Write your MySQL query statement below
SELECT a.NAME FROM Employee a, Employee b
WHERE a.ManagerId = b.Id AND a.Salary > b.Salary;

LeeCode(Database)-Employees Earning More Than Their Managers的更多相关文章

  1. 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, ...

  2. [LeetCode] Employees Earning More Than Their Managers 员工挣得比经理多

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  3. Leetcode 181. Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  4. [SQL]LeetCode181. 超过经理收入的员工 | Employees Earning More Than Their Managers

    SQL架构 Create table If Not Exists Employee (Id ), Salary int, ManagerId int) Truncate table Employee ...

  5. 【SQL】181. Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  6. LeetCode - Employees Earning More Than Their Managers

    Description: The Employee table holds all employees including their managers. Every employee has an ...

  7. 181. Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  8. Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  9. LeetCode——Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

随机推荐

  1. UESTC_Just a Maze CDOJ 1162

    Just a Maze Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 262144/262144KB (Java/Others) Su ...

  2. phpcms加载系统类与加载应用类之区别详解

    <?php 1. 加载系统类方法load_sys_class($classname, $path = ''", $initialize = 1)系统类文件所在的文件路径:/phpcms ...

  3. Unity 开发游戏Game分辨率设置

    最近自己开发小游戏,突然又被Game视图中设置分辨率被诱惑了, 我到底该怎么设置分辨率设置的图片才能让电脑和手机尺寸显示的大小一模一样呢? 然后又被手机尺寸和分辨率迷惑了! =.= 越搞越混   分辨 ...

  4. python学习之路-3 初始python数据类型以及文件操作

    本篇涉及内容 set集合 函数 三元运算 文件操作 set集合 set是一个无序的且不重复的元素集合 1.创建set集合的方法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...

  5. mycat(4)

    2016二月 24 置原 配置MyCat-eye 接下来在开始使用MyCat之前,我们先把监控平台部署好. 下载MyCat-eye项目,mvn打包. 之后得到类似于Mycat-web-1.0-SNAP ...

  6. 几个检查当前运行的LINUX是在VM还是在实体机中的方法

    昨天提到了VM中的逃逸问题,要想逃逸,首先要检测当前操作系统是否为VM,下面提供几个LINUX下的检查方法: 第一,首推facter virtual ,权限为普通用户,约定,普通用户命令提示符用$表示 ...

  7. html链接

    1. <a href="/index.html">本文本</a> 是一个指向本网站中的一个页面的链接.</p><p><a hr ...

  8. 网络编程之TCP

    知识补充:源IP地址和目的IP地址以及源端口号和目的端口号的组合称为套接字.其用于标识客户端请求的服务器和服务. TCP编程的实现步骤:服务器端:1.通过ServletSocket创建绑定到指定客户端 ...

  9. android设置图片变化的四种效果代码

    activity代码如下: package com.example.chapter12_graphic_animation; import android.os.Bundle; import andr ...

  10. UVA 227 Puzzle - 输入输出

    题目: acm.hust.edu.cn/vjudge/roblem/viewProblem.action?id=19191 这道题本身难度不大,但输入输出时需要特别小心,一不留神就会出问题. 对于输入 ...