博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
181. Employees Earning More Than Their Managers
阅读量:4569 次
发布时间:2019-06-08

本文共 877 字,大约阅读时间需要 2 分钟。

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      |+----------+ 自连接 找出比其上司挣得更多的员工 MySQL(1686ms):
1 SELECT e1.Name AS Employee2 FROM Employee AS e1 , Employee AS e23 WHERE e1.ManagerId = e2.Id4   AND e1.Salary > e2.Salary ;

 

转载于:https://www.cnblogs.com/mengchunchen/p/8317650.html

你可能感兴趣的文章
spring源码学习——spring整体架构和设计理念
查看>>
模拟window系统的“回收站”
查看>>
报文格式【定长报文】
查看>>
RDLC报表钻取空白页问题
查看>>
多路电梯调度的思想
查看>>
jQuery-对Select的操作
查看>>
过滤器、监听器、拦截器的区别
查看>>
为什么要进行需求分析?通常对软件系统有哪些需求?
查看>>
一些模板
查看>>
jquery和dom元素相互转换
查看>>
放大的X--HDOJ-201307292012
查看>>
题目831-签到-nyoj-20140818
查看>>
百词斩-斩家秘籍
查看>>
php反射
查看>>
Mysql主从配置,实现读写分离
查看>>
ES6中的Symbol
查看>>
1.8小结
查看>>
浅谈C#关于AOP编程的学习总结
查看>>
无障碍阅读
查看>>
bzoj1494 生成树计数 (dp+矩阵快速幂)
查看>>