Need assistance with merging duplicate records based on dates in two different fields

  • This one has me a stumped and I admit my SQL skills are limited at best.
    If I have the sets of duplicate records below except for the dates, how to query to  get the result shown in the two bottom rows?
    Thanks in advance

  • From what I can see, you're looking for the earliest start date and latest d date?


    SELECT    A.[From],
            A.[To],
            A.Company,
            A.Vehicle,
            MIN(A.StartDate),
            MAX(A.EndDate)
    FROM    dbo.ExampleTable AS A
    GROUP    BY A.[From],
            A.[To],
            A.Company,
            A.Vehicle;    

  • Thank you for the quick reply and I appreciate the info.
    Everything I was trying was so convoluted and complicated!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply