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  | 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 e.name as ‘Employee‘
            from Employee e,Employee m
                where e.managerid=m.id
                    and
                       e.salary>m.salary;
    内连接
        select e.name as Employee
            from employee e inner join employee m
                on e.managerid=m.id and e.salary>m.salary;
时间: 2024-10-13 16:25:43

Employees Earning More Than Their Managers的相关文章

Database 181. 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 Joe 70000 3 2 Henry 80000 4 3 Sam 60000 NULL 4 Max 90000 NULL Given the Employee

【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 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

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

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, and there is also a column for the manager Id. +----+-------+--------+-----------+ | Id | Name | Salary | ManagerId | +----+-------+--------+--------

【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 |

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