I\'ve been stumped with some SQL where I\'ve got several rows of data, and I want to subtract a row from the previous row and have it repeat all the way down.
So her
edit: fixed when re-read Q (misunderstood)
SELECT f.id, f2.id, f.length, f2.length, (f.length -f2.length) AS difference FROM foo f, foo f2 where f2.id = f.id+1
id was ambiguous
edit: note: tested in mysql 5.0