I have two tables, one with employee details looks like this
Employee ID | Employee Name | Start Date | Termination Date |
2234 | John Smith | 2014-01-03 | |
3333 | Jane Doe | 2014-04-22 | 2014-10-31 |
1234 | Bobby Wilson | 2013-12-10 | |
My second table has there sales by month-year
looks like so
Employee ID | 2013-12 | 2014-01 | 2014-02 | 2014-03 | 2014-04 | etc | etc
2234 | | 199.99 | 130.00 | 300.00 | 230.99 | etc | etc
3333 | | | | | 204.02 | etc | etc
1234 | 455.99 | 332.32 | 334.00 | 553.00 | 334.99 | etc | etc
So what i need is to make a new Query that helps me show the trend of the employee on how their first month employeed sales number looks like, second month sales, third moneth sales etc. based on when the month one being when the employee started. Over a spand of 12 month or more
So the new table would look as follows
Employee | Month 1 | Month 2 | Month 3 | Month 4 | etc | etc |
2234 | 199.99 | 130.00 | 300.00 | 230.99 | etc | etc |
3333 | 240.02 | (month 2) | (month 3)| (month 4)| etc | etc |
1234 | 455.99 | 332.32 | 334.00 | 553.00 | etc | etc |
So I know we can join the two tables by Employee ID and I know we can determine an employee's month one based on their start date but how do you write this query out in SQL?