Created
February 1, 2012 16:05
-
-
Save artyom/1717729 to your computer and use it in GitHub Desktop.
subsequent rows values difference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sqlite> select * from t1; | |
i n | |
a 1 | |
b 2 | |
c 3 | |
d 4 | |
e 5 | |
foo 15 | |
bar 37 | |
baz 115 | |
zzz 85 | |
sqlite> select t1.i, t2.i, t1.n, t2.n, t1.n-t2.n as difference from t1, t1 as t2 where t1.oid=t2.oid+1; | |
i i n n difference | |
b a 2 1 1 | |
c b 3 2 1 | |
d c 4 3 1 | |
e d 5 4 1 | |
foo e 15 5 10 | |
bar foo 37 15 22 | |
baz bar 115 37 78 | |
zzz baz 85 115 -30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment