For the given data:
+---+--------+------+
|CID| number | rum |
+---+--------+------+
| 1 | 1.0000 | NULL |
| 3 | 2.0000 | NULL |
| 5 | 2.0000 | NULL |
| 6 | 4.0000 | NULL |
+---+--------+------+
I want to calculate rum with percentage change of current and previous number.
rum = (currNumber - prevNumber) / prevNumber * 100
Expected result:
+---+--------+------+
|CID| number | rum |
+---+--------+------+
| 1 | 1.0000 | NULL |
| 3 | 2.0000 |100.0 |
| 5 | 2.0000 | 0.0 |
| 6 | 4.0000 |100.0 |
+---+--------+------+
LAG
function doesn't work here in MySQL.