Employees Earning More Than Their Managers Leetcode SQL

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      |

+----------+

这题用的是self join 的方法 选出 ManagerID 再将Salary作为比较条件即可得到答案。

# Write your MySQL query statement below
SELECT A.Name From Employee A,Employee B
WHERE A.ManagerId=B.Id and A.Salary>B.Salary
时间: 2024-08-26 05:30:31

Employees Earning More Than Their Managers Leetcode SQL的相关文章

【leetcode SQL】Employees Earning More Than Their Managers

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 |

LeetCode SQL:Employees Earning More Than Their Managers

# Write your MySQL query statement below SELECT a.Name FROM Employee AS a INNER JOIN Employee AS b ON a.ManagerId = b.Id WHERE a.Salary > b.Salary 让我来看看讨论区,并没有发现更好的

leetcode 181. Employees Earning More Than Their Managers

题目链接: https://leetcode.com/problems/employees-earning-more-than-their-managers/ The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+---------

【Leetcode】Employees Earning More Than Their Managers

题目链接:https://leetcode.com/problems/employees-earning-more-than-their-managers/ 题目: 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

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

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 |

LeetCode - 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. Given the Employee table, write a SQL query that finds out employees who earn more than their manag

[LeetCode]Employees Earning More Than Their Managers,解题报告

目录 目录 题目 思路 AC SQL 题目 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 G

LeetCode OJ Employees Earning More Than Their Managers

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 |

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

SQL架构 1 Create table If Not Exists Employee (Id int, Name varchar(255), Salary int, ManagerId int) 2 Truncate table Employee 3 insert into Employee (Id, Name, Salary, ManagerId) values ('1', 'Joe', '70000', '3') 4 insert into Employee (Id, Name, Sala