First, I would add an id column to the table so that you have something that grows predictably from row to row.
Then I will try the following query:
SELECT t1.Time AS 'Starttime', t2.Time AS 'Endtime', (t2.Value - t1.Value) AS 'Change' FROM SensorData t1 INNER JOIN SensorData t2 ON (t2.id - 1) = t1.id ORDER BY t1.Time ASC
I'm going to create a test pattern to try it for myself, so I donโt know if it works yet, but it's worth it!
Update Fixed with one minor problem (CHANGE is a protected word and should have been indicated), but verified and it works! It gives exactly the results defined above.
Brendan bullen
source share