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

后端 未结 7 1342
臣服心动
臣服心动 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:46

    Try this also:

    Select e.ename, e.sal, e.deptno
    from (select e.*, avg(sal) over (partition by deptno) as avgsalary
          from EMP_TABLE e
         ) e
    where e.sal > e.avgsalary;
    
    0 讨论(0)
提交回复
热议问题