I have identified overlapping dates from trainers that trained users between a start date and end date. I now need to identify those USER_IDs where the end date for one of their trainers is the same as the start date for their next trainer. I need to flag them 'Y' and 'N'.
I run into a problem when there are trainers who have the same start date and end date as the prior trainers end date for the USER_ID.
UPDATE #SERVICE A
SET DIS_ADM_MATCH = CASE WHEN B.FROM_DATE = A.TO_DATE OR
A.FROM_DATE = B.TO_DATE
THEN 'Y' ELSE 'N' END
FROM #SERVICE A
INNER JOIN #SERVICE B
ON A.USER_ID = B.USER_ID
AND A.TRAINER_ID <> B.TRAINER_ID;