# 题目

#184 Department Highest Salary

# 解题思路&一种答案

## 第一步

maxSalary DepartmentId
90000 1
80000 2

MySQL extends the use of GROUP BY so that the select list can refer to nonaggregated columns not named in the GROUP BY clause. This means that the preceding query is legal in MySQL. You can use this feature to get better performance by avoiding unnecessary column sorting and grouping. However, this is useful primarily when all values in each nonaggregated column not named in the GROUP BY are the same for each group. The server is free to choose any value from each group, so unless they are the same, the values chosen are indeterminate.

## 第二步

Department Salary DepartmentId
IT 90000 1
Sales 80000 2

## 第三步

Department Name Salary
Sales Henry 80000
IT Max 90000
IT Tom 90000

# 注意事项

• 最高工资有多个人时，需要把所有人都查询出来
• 对应的 DepartmentId 行不存在

# 构造测试数据

Department Name Salary
Sales Henry 80000
IT Max 90000
IT Tom 90000