I am befumped and befuddled.
I have a table with bunches o' records of employee data. Employees move between various departments often and a tenure of how long they were in their latest department is needed.
Unfortunately, every move and change in a department is kept in this table. For example, Bob was in dept #1 for two years on first shift, dept #3 for three years on second shift, dept#1 for three more years on first shift, then dept #1 for 2 years on second shift.
For Bob, the query would need to sum the five total most recent years in dept #1.
A query to just pull up the most recent years in a department won't work because it would lose the immediately prior tenure in dept #1 on a different shift. So, it would have to find all records for an employee in a department, summing the years, where there was no break in department code, regardless of other activities, like shift changes.
Clear as mud?
I have a table with bunches o' records of employee data. Employees move between various departments often and a tenure of how long they were in their latest department is needed.
Unfortunately, every move and change in a department is kept in this table. For example, Bob was in dept #1 for two years on first shift, dept #3 for three years on second shift, dept#1 for three more years on first shift, then dept #1 for 2 years on second shift.
For Bob, the query would need to sum the five total most recent years in dept #1.
A query to just pull up the most recent years in a department won't work because it would lose the immediately prior tenure in dept #1 on a different shift. So, it would have to find all records for an employee in a department, summing the years, where there was no break in department code, regardless of other activities, like shift changes.
Clear as mud?