我有一张这样的表
employeeid | departmentid | bossid | name | salary
我需要找到最高薪水,但是对于每个不同的离职人员。
答案 0 :(得分:0)
将GROUP BY
与汇总功能MAX()
一起使用:
SELECT MAX(salary), departmentid FROM your_table GROUP BY departmentid;
答案 1 :(得分:0)
您可以使用group by
子句围绕departmentid
构建一个组。对于该组,您可以使用聚合函数对每个组的数据运行操作,如max()
select departmentid,
max(salary) as max_sal
from employees
group by departmentid
答案 2 :(得分:0)
SELECT DepartmentId, MAX(SALARY) AS Salary
FROM EmployeesTable
GROUP BY DepartmentId
答案 3 :(得分:0)
select departmentid, max(salary) as salary
from yourtab
group by departmentid