lundi 25 avril 2016

sqlite Calculate Difference between current and previous rows

I been looking for answer all day but can't find any. The best what I did find is function lag but it is not for sqlite. I have table please see picture attached. What I need is calculate speed. That would be (rotations in current row - rotations in previous row). So at speed column row3 would be 6. In speed row4 would be 5. And so on. I used this code but no luck.

`select training.id,
 training.tim , 
 training.rotations,
 (training.rotations-training2.rotations) as speed 
 from training training left outer  JOIN training  training2 
 on training.id = training2.id`
 ` 

my Table

Table name is training.

Aucun commentaire:

Enregistrer un commentaire