Hi! I am trying to calculate the difference in salaries, from one year to the next for every employee.
For the sake of simplicity, I have a table that takes a snapshot of employee salaries once a year. It has these fields:
ID, SALARY, YEAR
I want to use SQL to create a new table that contains each employees ID and the difference in their salary between the 2011 snapshot and the 2012 snapshot. It simply needs to contain:
ID, SALCHANGE
SALCHANGE will be the difference between the employees salary at the 2011 snapshot and the 2012 snapshot.
My current solution is very crude. I selected all of the id's and salaries for 2011 into one table and all of the ids and salaries for 2012 into another table. I then joined the 2011 and 2012 tables and created a new column that is the difference between the 2011 and 2012 salary values.
For the sake of simplicity, I have a table that takes a snapshot of employee salaries once a year. It has these fields:
ID, SALARY, YEAR
I want to use SQL to create a new table that contains each employees ID and the difference in their salary between the 2011 snapshot and the 2012 snapshot. It simply needs to contain:
ID, SALCHANGE
SALCHANGE will be the difference between the employees salary at the 2011 snapshot and the 2012 snapshot.
My current solution is very crude. I selected all of the id's and salaries for 2011 into one table and all of the ids and salaries for 2012 into another table. I then joined the 2011 and 2012 tables and created a new column that is the difference between the 2011 and 2012 salary values.