Leetcode MySQL exercise one – employees who exceed the manager’s income

Time:2021-10-23

The employee table contains all employees, and their managers also belong to employees. Each employee has an ID and a list of the ID of the manager corresponding to the employee.

Id Name Salary ManagerId
1 Joe 70000 3
2 Henry 80000 4
3 Sam 60000 NULL
4 Max 90000 NULL

The Department table contains information about all departments of the company.

Id Name
1 IT
2 Sales

Write an SQL query to find out the highest paid employees in each department. For example, according to the table given above, Max has the highest salary in the IT department and Henry has the highest salary in the sales department.

Department Employee Salary
IT Max 90000
Sales Henry 80000
    SELECT e.Name AS Employee
    FROM Employee e, Employee e1
    WHERE e.ManagerId = e1.id
        AND e.Salary > e1.Salary;

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Yong Li Gao

Recommended Today

Ffmpeg plays RTSP / webcam stream

This article will introduce how ffmpeg plays RTSP / webcam / file streams. The process is as follows: RTSP/Webcam/File > FFmpeg open and decode to BGR/YUV > OpenCV/OpenGL display code:https://github.com/ikuokuo/rt…, sub module RTSP local player Ffmpeg preparation git clone https://github.com/ikuokuo/rtsp-wasm-player.git cd rtsp-wasm-player export MY_ROOT=`pwd` # ffmpeg: https://ffmpeg.org/ git clone –depth 1 -b n4.4 https://git.ffmpeg.org/ffmpeg.git $MY_ROOT/3rdparty/source/ffmpeg […]