Jiyu
  • Blog
  • Dev
  • Leetcode
  • |
  • 中文

181. Employees Earning More Than Their Managers

March 23, 2022
sql

Employees Earning More Than Their Managers - LeetCode

| id | name | salary | managerId |

Write an SQL query to find the employees who earn more than their managers.


  • code
SELECT
    a.Name AS 'Employee'
FROM
    Employee AS a,
    Employee AS b
WHERE
    a.ManagerId = b.Id
        AND a.Salary > b.Salary
;
  • code
select e1.name as "Employee" from Employee e1 inner join Employee e2 on e1.managerId = e2.id
where e1.salary > e2.salary
« 176. Second Highest Salary
197. Rising Temperature »
    array 93
    backtracking 20
    bfs 24
    bible 1
    binarysearch 27
    binarysearchtree 14
    binarytree 25
    bit 17
    china 5
    christian 5
    design 8
    dfs 30
    docker 2
    documentary 2
    dostoevsky 1
    dp 41
    dynalist 3
    flask 1
    graph 11
    greedy 16
    hashtable 22
    health 1
    heap 15
    hugo 3
    intellij 2
    java 8
    javascript 1
    leetcode-summary 13
    linkedlist 33
    linux 2
    math 33
    poetry 4
    psychology 4
    python 3
    queue 7
    recursion 6
    remix 1
    segmenttree 1
    slidingwindow 6
    sorting 11
    spring 8
    spring-in-action 4
    sql 12
    stack 23
    string 36
    tool 12
    topological 3
    travel 1
    tree 12
    trie 10
    twopointers 10
    unionfind 9
    vscode 2
    warwick 5
    wittgenstein 3