LeetCode-SQL-184. The highest paid sector employees

https://leetcode-cn.com/problems/department-highest-salary/

Forgive my ignorance. . . Long exposure dual fields in. . .

SELECT
    Department.name AS 'Department',
    Employee.name AS 'Employee',
    Salary
FROM
    Employee
        JOIN
    Department ON Employee.DepartmentId = Department.Id
WHERE
    (Employee.DepartmentId , Salary) IN
    (   SELECT
            DepartmentId, MAX(Salary)
        FROM
            Employee
        GROUP BY DepartmentId
	)
;

 

Published 137 original articles · won praise 2 · views 20000 +

Guess you like

Origin blog.csdn.net/m0_37302219/article/details/104949110