How do I lag columns in MySQL?
Consider the following table: SELECT id, value FROM table ORDER BY id ASC; +-----+---------+ | id | value | +-----+---------+ | 12 | 158 | | 15 | 346 | | 27 | 334 | | 84 | 378 | | 85 | 546 | +-----+---------+ The id column is auto-incremented but contains gaps. The value column is numeric. I want to look at the increase in value over time by setting value in relation to the value two rows above. That is for row id=85 I want to set the value of row id=85 (546) in relation to the value of row id=27 (334). The value to be computed for row id=85 is hence 546/334=1.63473. This is the result I want