I have a table EmpDetails:
EmpDetails
DeptID EmpName Salary Engg Sam 1000 Engg Smith 2000 HR Denis 1500 HR
select empno from EMP e where salary=(select max(sal) from EMP w where groupby w.deptno having e.deptno=w.deptno)
I hope it will work...