[Solved] How to consolidate overlap date in single


Now that I understand your issue, just subtract the 2 dates to determine the time frame difference:

SELECT S.Id, S.Start_dt, S.End_dt, S.Division
FROM Sample S
 JOIN (
   SELECT S.Id, Max(S.end_dt-S.start_dt) as timeframe
FROM Sample S
GROUP BY S.Id ) S2 ON S.Id = S2.Id 
    AND S.end_dt-S.start_dt = s2.timeframe

Here is the Fiddle.

Good luck.

3

solved How to consolidate overlap date in single