I want to calculate the rest of a driver, and for this I have the following table:
What I want to do is to calculate for each driver, the largest rest expressed in Hours.
For this I have to do the subtraction between the departure and the arrival of the previous trip.
For example, Salida (id_viaje=20) - Llegada (id_viaje=19)
, but keep in mind that not always the id_viaje
will be the previous number, since in the middle there may be a record for another driver.
I do not know if I have explained myself correctly, any doubt I will try to solve it!
PS: do not listen to the data in the table, they are simply tests, I know they do not make sense!