I have a table of increasing dates (with gaps) and corresponding values
date | value
01.02.2012 | 10
02.02.2012 | 11
03.02.2012 | 33
07.02.2012 | 34
08.02.2012 | 13
I am looking for table of differences for values between dates, like this:
02.02.2012 - 01.02.2012 | 11 - 10 = +1
03.02.2012 - 02.02.2012 | 33 - 11 = +22
07.02.2012 - 03.02.2012 | 34 - 33 = +1
08.02.2012 - 07.02.2012 | 13 - 34 = -21
Now I am load table into excel and make calculations there, but I have feeling there is a possible way of getting it by use of sql commands inside database. Is there any?
UPD. Actually I use access as database system, but If there is a difference I can switch to one that best fit.
Since I don’t think analytical functions like
Lagare available in access you will need to use a correlated subquery: