• You need some additional bchages as well as Dwain's correction, in order to handle the hvehicle history correctly.

    First remove

    INNER JOIN History H ON H.VehicleID=V.VehicleID

    (actually since the Vehicles table isn't needed for this query you should remove

    INNER JOIN Vehicles AS V

    as well.)

    Then change the SELECT line to

    SELECT (SELECT DriverName from History H

    WHERE H.ReceivedDate = (SELECT MAX(ReceivedDate) from History H2 where H2.VehicleID = R.VehicleID and H2.ReceivedDate <= R. RepairDate)

    AND H.VehicleID = R.VehicleID) AS DriverName, R.RepairCost, R.RepairDate

    I haven't checked that this works with your data because I can't get the data to load, but it should show you what needs doing even if it doesn't work - you need to get who owned the vehicle at the repair date, by looking for the latest history date for the vehicle which isn't after the repair date and then extracting the driver name from the history record with that history date and vehicleID.

    Tom