2
I have a table carro_log that stores 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 calculation of the car yield is (current kilometer - previous kilometer) / current fuel of each id (car). How can I do this? Select and subtract the current and previous value from the same column?
For a given id (car), the last record is the current one, and the previous one is the immediately smaller date?
– Ismael
For the same id, yes.
– iperion300