Mysql
 sql >> Base de données >  >> RDS >> Mysql

SÉLECTIONNER chaque employé qui a un salaire supérieur à la MOYENNE de son département

veuillez essayer avec la requête ci-dessous

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)

ou

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)