• I don't see a solution to your problem in a single query. The problem lies in the assignment of a unique Trip_ID in the new table.

    However, you could do it in two goes. First insert one record for each trip using an identity field for Trip_id. After that remove the identity (or 'set IDENTITY_INSERT OFF') and insert all records that are not yet present.

    The query that was posted by AnzioBake is a good start to identify records belonging to the same trip.