-4

我有一张这样的桌子

employeeid | departmentid | bossid | name | salary

我需要找到最高工资,但对于每个不同的部门ID。

4

4 回答 4

0
于 2013-09-10T21:24:05.490 回答
0

您可以使用该group by子句围绕departmentid. 对于该组,您可以使用聚合函数对每个组的数据运行操作,例如max()

select departmentid,
       max(salary) as max_sal
from employees
group by departmentid
于 2013-09-10T21:24:08.230 回答
0

您需要使用MAXGroup By

SELECT DepartmentId, MAX(SALARY) AS Salary
FROM EmployeesTable
GROUP BY DepartmentId
于 2013-09-10T21:24:14.543 回答
0
select departmentid,  max(salary) as salary
from yourtab
group by departmentid
于 2013-09-10T21:24:47.010 回答