Mysql
 sql >> Database >  >> RDS >> Mysql

SELEZIONA ogni dipendente che ha uno stipendio superiore alla MEDIA del suo dipartimento

si prega di provare con la query di seguito

Select * from employee a where Employee_Salary > (select avg(Employee_Salary) from 
employee b group by Department_ID having b.Department_ID = a.Department_ID)

o

Select * from employee a where Employee_Salary> (select avg(Employee_Salary) from 
employee b where b.Department_ID = a.Department_ID group by Department_ID)