I have a carro_log
table that keeps the update history of another table.
id kilometragem combustivel dt_atualização
1 200 45 2017-05-03
2 400 35 2017-05-03
1 150 38 2017-05-02
3 220 30 2017-05-01
. . . .
. . . .
The car yield calculation is (current mileage - previous mileage) / current fuel of each id (car). How can I do this? Select and subtract the current and previous value from the same column?