반응형
```SELECT d.name as Department, eee.name as Employee, ee.salary as salary
FROM (SELECT e.departmentId, MAX(e.salary) as salary FROM Employee e GROUP BY e.departmentID) ee JOIN Department d on d.id = ee.departmentId
JOIN Employee eee ON eee.salary = ee.salary and ee.departmentID = eee.departmentID```
```
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
)
;
반응형