Reputation: 175
I have this table :
2017-10-29 10.812999999999999
2017-10-30 1.883
2017-10-31 15.746
2017-11-01 29.156
2017-11-02 42.552
I want to do the difference of the next day to the day before.
Example of output desired :
2017-10-29 (1.88-10.81)=-8,93
2017-10-30 13,863
etc...
Upvotes: 1
Views: 54
Reputation: 1270463
You can use a left join
:
select t.*, (t.val - tnext.val) as diff
from t left join
t tnext
on t.date = tnext.date - interval 1 day;
Upvotes: 2