Highest Salary in each department

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

I have a table EmpDetails:

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


        
30条回答
  •  猫巷女王i
    2021-01-30 23:02

    ***
    
    > /*highest salary by each dept*/
    
    ***
    select d.Dept_Name,max(e.salary)
        from emp_details as e join Dept_Details as d
        on e.d_id=d.Dept_Id
        group by  d.Dept_Name
    
    select  distinct e.d_id,d.Dept_Name
        from emp_details as e join Dept_Details as d 
        on e.d_id=d.Dept_Id
    
    select  e.salary,d.Dept_Name,d.Dept_Id
        from emp_details as e join Dept_Details as d 
        on e.d_id=d.Dept_Id
    
    /////simplest query for max salary dept_wise////
    

提交回复
热议问题