fmsol
asked on
How to find first startdate and last enddate for multiple-position employees for all departments
We have several employees with multiple positions; some subsequent in same department, some in different departments (or a mix of both).
I need to find for each employee the first startdate and last enddate for their positions in each department (ie group by employee and dep)
Simplified tables:
Emp: empID, name
Dep: depID, name
Positions: empID, DepID, startdate, enddate
I need to find for each employee the first startdate and last enddate for their positions in each department (ie group by employee and dep)
Simplified tables:
Emp: empID, name
Dep: depID, name
Positions: empID, DepID, startdate, enddate
Are you interested in knowing whether there were any employment gaps?
I assume that your Positions table will not allow anyone (EmpID) to be assigned to more than one department (DepID) at any time. How are you dealing with situations where they start in one department, move to another, then move back to the original?
I assume that your Positions table will not allow anyone (EmpID) to be assigned to more than one department (DepID) at any time. How are you dealing with situations where they start in one department, move to another, then move back to the original?
ASKER
Thank you Jim; of course, so simple.
But to make it more complicated: yes Dale, I need to know if there are employment gaps
But to make it more complicated: yes Dale, I need to know if there are employment gaps
ASKER
... and our Positions table will allow more than one department at the same time (this is hospital employees)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the grade. Good luck finding the overlaps. -Jim
Open in new window
If you'd like some more reading on GROUP BY I have an image and code-heavy tutorial out there called SQL Server GROUP BY Solutions