181. Employees Earning More Than Their Managers

原创 2016年08月30日 12:47:41

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 e1.Name AS Employee
FROM Employee e1,Employee e2
WHERE e1.Salary > e2.Salary 
AND e1.ManagerId = e2.Id;






版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

【Leetcode Database】Employees Earning More Than Their Managers

题目: The Employee table holds all employees including their managers. Every employee has an Id...

Employees Earning More Than Their Managers --- 找出比经理工资高的员工

LeetCode练习题

Why do business analysts and project managers get higher salaries than programmers?

From: http://programmers.stackexchange.com/questions/45776/why-do-business-analysts-and-project-man...

【ios】Displaying on the app Store in More Than One Language

After you create an iTunes Connect record for your app, you can update the record with localized tex...

Gain more than oracle 2

  • 2015年12月08日 14:50
  • 29.34MB
  • 下载

Love you more than JavaScript

  • 2012年02月13日 23:58
  • 1.36MB
  • 下载

MySQL创建索引抛出“required more than 'innodb_online_alter_log_max_size' bytes of modification log”异常的解决方案

1.问题描述 为两台机器上MySQL Server中zabbix2数据库history_unit表创建idx_clock(clock)索引时出现异常。 执行的SQL语句如下: alter tab...

Open Source – More Than Just Code

  • 2012年12月16日 14:14
  • 2.85MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:181. Employees Earning More Than Their Managers
举报原因:
原因补充:

(最多只允许输入30个字)