Leetcode 181.超过经理的收入 (SQL题解)
2019-09-15 22:33
113 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/jhhh512722654/article/details/100866676
SQL架构
Employee表包含所有员工,他们的经理也属于员工。每个员工都有一个 Id,此外还有一列对应员工的经理的 Id。
+----+-------+--------+-----------+ | Id | Name | Salary | ManagerId | +----+-------+--------+-----------+ | 1 | Joe | 70000 | 3 | | 2 | Henry | 80000 | 4 | | 3 | Sam | 60000 | NULL | | 4 | Max | 90000 | NULL | +----+-------+--------+-----------+
给定
Employee表,编写一个 SQL 查询,该查询可以获取收入超过他们经理的员工的姓名。在上面的表格中,Joe 是唯一一个收入超过他的经理的员工。
+----------+ | Employee | +----------+ | Joe | +----------+
题解:SQL语句知识点回顾,除去经理为空数据进行优化。
[code]# Write your MySQL query statement below select e1.Name as Employee from Employee e1 ,Employee e2 where e1.ManagerId is not null and e1.ManagerId = e2.Id and e1.Salary > e2.Salary;
相关文章推荐
- 181. 超过经理收入的员工
- LeetCode(181)-超过经理输入的员工
- 181.超过经理收入的员工
- Leetcode no. 181 (sql)
- 【sql学习】LeetCode之181. Employees Earning More Than Their Managers
- Leetcode的SQL题解:185. 部门工资前三高的员工
- leetcode_sql_3,181,182,183
- LeetCode探索之旅(45)-181求工资比经理高的员工
- [LeetCode] Leetcode 题解索引 (C++/Java/Python/Sql)
- LeetCode数据库题解&&sql相关知识总结
- [LeetCode] [SQL]: 181: Employees Earning More Than Their Managers
- LeetCode题解:N-Queens I and II
- [LeetCode]题解(python):013-Roman to Integer
- LeetCode 135:candy 题解 Python
- LeetCode题解——Container With Most Water
- clob字段只能写入4k内容,超过后报null at org.apache.openjpa.jdbc.sql.OracleDictionary.putString
- Leetcode 题解系列(十七)
- LeetCode题解:ZigZag Conversion
- Leetcode题解(二)
- leetcode题解-268. Missing Number