So here is the problem i'm trying to update column distance, first to sum the distance for each ownerID and after when there is a record with the same id address the first record should memories thee distance and the second should be 0.000
This is the expected result
So far I did the first part that calculates the distance using this code
UPDATE Action_Distance
SET [distance]=(SELECT sum([distance])
FROM Action a2
WHERE [name]='travel' and a2.ownerID = Action_Distance.ownerId
)
WHERE [name]='drive_through'
I don't understand how it should be done.