Advertisement
kyamaliev

AvgSalaryByDepartmentID

Feb 14th, 2015
256
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT DISTINCT avgSalary.[Average Salary], e.DepartmentID, d.Name
  2. FROM Departments AS d
  3. JOIN Employees AS e ON e.DepartmentID = d.DepartmentID
  4. JOIN (
  5.     SELECT AVG(Salary) AS [Average Salary], DepartmentID
  6.     FROM Employees
  7.     GROUP BY DepartmentID
  8.     HAVING DepartmentID = 1
  9. ) AS avgSalary
  10. ON avgSalary.DepartmentID = e.DepartmentID
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement