Long time lurker, first time asking a question. If I make any etiquette mistakes, please correct me.
Goal: Get the time an individual started and ended a position based on their job code and team code. So if someone left a position, then later returned to the position I would like it to give me two "Start Dates" in that position.
Data Table / Format: My data table includes a weekly snapshot taken every Sunday of every employee, their employeeID, their job code, their team code, and then other stuff. Here's a (fake) example. Variable types in ().
EID JobCode TeamCode weekstartdate
(INT) (VARCHAR) (INT) (DATETIME)
1 INT111 142 2022-02-20 00:00:00.00
1 INT111 142 2022-02-27 00:00:00.00
I have tried something along the lines of
Select EID,Jobcode,teamcode,MIN(weekstartdate)
from #Dataset
group by EID,Jobcode,Teamcode
The struggle is that if someone has left and returned to the job, it would only show their original weekstartdate. Where I need only uninterrupted time in the position.
If anyone can point me towards functions or features I don't know about that could help with this, I would appreciate it.