I am working with an application that is built with Visual FoxPro 6.0
, at this moment I need to make a query that allows a record within a SELECT to obtain information from the immediately previous record to perform a calculation.
The calculation is simply between date fields, which should allow a record to determine how much time has passed with respect to the same field as the previous record.
The query I am looking for is something similar to the following (simply an idea):
SELECT
fila,
fecha,
(fecha - fecha<del registro anterior>) as tiempo_transcurrido
FROM
tabla
And the result that I hope to obtain is the following:
fila fecha tiempo_tiempo_transcurrido
1 2017-04-07 00:00:00 0
2 2017-04-07 00:00:10 10
3 2017-04-07 00:00:15 5
4 2017-04-07 00:01:00 45
NOTE: I can not use own functions of SQL Server
, ORACLE
or MySQL
because I am working on the engine of Visual FoxPro 6.0