SELECT every employee that has a higher salary than the AVERAGE of his department

后端 未结 7 1343
臣服心动
臣服心动 2021-01-13 23:46

I have only 1 table named EMPLOYEE on my database with the 3 following collumns:

Employee_Name, Employee_Salary, Department_ID
7条回答
  •  走了就别回头了
    2021-01-14 00:38

    you can try this way as well !

      select FirstName,E.DepartmentName,BaseRate,EB.avgSAL
      From DimEmployee E
      inner join
      (select avg(BaseRate) As avgSAL,DepartmentName
      from DimEmployee
      group by DepartmentName ) EB
      ON E.DepartmentName = Eb.DepartmentName
      where E.BaseRate > Eb.avgSAL
    

提交回复
热议问题