I have a table EmpDetails:
EmpDetails
DeptID EmpName Salary Engg Sam 1000 Engg Smith 2000 HR Denis 1500 HR
Not sure why no one has mentioned the Group By .... Having syntax. It specifically addresses these requirements.
select EmpName,DeptId,Salary from EmpDetails group by DeptId having Salary=max(Salary);