Highest Salary in each department

前端 未结 30 1463
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 22:16

I have a table EmpDetails:

DeptID      EmpName   Salary
Engg        Sam       1000
Engg        Smith     2000
HR          Denis     1500
HR                  


        
30条回答
  •  孤独总比滥情好
    2021-01-30 23:10

    If you want to show other parameters too along with DeptId and Salary like EmpName, EmpId

    SELECT 
            EmpID 
          , Name, 
          , Salary
          , DeptId 
       FROM Employee 
       where 
         (DeptId,Salary) 
         in 
         (select DeptId, max(salary) from Employee group by DeptId)
    

提交回复
热议问题