I need help with a join/script that needs to reference both keys in order to narrow the data.
Below is a sample of the data that I'm working with:
OnboardingID AboutTypeID ReferenceID OnboardingState
1 5 1009 6
2 5 1010 5
3 6 132456 6
4 6 178945 6
5 5 1011 4
6 6 165489 5
The AboutTypeID equates to the EmployeeID (6) and their requisition/job ID (5). In other words, ReferenceID #132456 (employee) is also related to ReferenceID #1009 (their requisition).
How can I write the join to determine, based upon the OnboardingState column and other joins needed, to narrow down when a particular employee has a requisition onboardingstatus of 5, but also has an employee onboardingstatus of 6? You can see in the fake joins below how they all tie together.
inner join dbo.employee e on dbo.onboardings.referenceID = e.employee_Id
inner join dbo.requisition r on dbo.onboardings.referenceid = r.requisitionID
dbo.requisition.EmployeeID = dbo.employee.employeeID