What is the average salary of the employees who takes charge of the sales of over 4 territories?
average salary = DIVIDE(SUM(Salary), COUNT(EmployeeID)); employees who takes charge of over 4 territories refers to EmployeeID WHERE COUNT(TerritoryID) > 4;
SELECT AVG(T1.Salary) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.EmployeeID HAVING COUNT(T2.TerritoryID) > 4