mysql - Find the Average salary deviation for an employee within department -


i have list of employees work within set of teams. trying figure out each year difference each employee’s salary department’s average. have been looking @ standard deviations i’m little stuck if need have sub select achieve this.

the table looks like:

enter image description here

i not have code show because stuck on aliases.

just break down task in simple tasks. let's find average salaries first:

select teamid, `year`, avg(salary) avgsal employees group teamid, `year` 

now, difference need subtract employee's salary average:

select e.employeeid, e.salary, a.avgsal, e.salary - a.avgsal diff employees e inner join  (     select teamid, `year`, avg(salary) avgsal     employees     group teamid, `year` ) on a.teamid = e.teamid , a.`year` = e.`year` 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -