I have an employee transaction dimension that is setup like the following
EmpTranID | EmpID | TranDate | Status |
1 | 1 | 1/1/2000 | Hire |
2 | 1 | 1/1/2004 | Pay Rate |
3 | 1 | 1/1/2005 | Pay Rate |
4 | 1 | 6/1/2005 | Termination |
5 | 1 | 4/15/2006 | Rehire |
6 | 1 | 1/1/2007 | Pay Rate |
7 | 1 | 6/1/2007 | Termination |
8 | 1 | 1/1/2011 | Rehire |
I am trying to calculate Years of Service by Subtracting the Total Days from the hire date from the sum of the days between the terminations and rehires.
I can get the total days easily by doing a datediff from the original hire date, but I'm not sure how to get a sum of days between each of the Termination and rehires.
Any help is appreciated.