Say there's a table like:
+----------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| date | date | NO | MUL | NULL | |
| system_value | decimal(16,2) | NO | | NULL | |
| account_id | int(11) | NO | MUL | NULL | |
| growth | tinyint(1) | NO | PRI | 0 | |
+----------------+---------------+------+-----+---------+----------------+
And some data are as below showed.
+----+------------+--------------+------------+--------+
| id | date | system_value | account_id | growth |
+----+------------+--------------+------------+--------+
| 1 | 2020-05-28 | 18.34 | 83266 | 0 |
| 2 | 2020-05-27 | 30.63 | 83266 | 0 |
| 3 | 2020-05-26 | 26.01 | 83266 | 0 |
| 4 | 2020-05-23 | 55.87 | 83266 | 0 |
| 5 | 2020-05-20 | 48.54 | 83266 | 0 |
| 6 | 2020-05-19 | 48.54 | 83266 | 0 |
| 7 | 2020-05-21 | 58.52 | 82155 | 0 |
| 8 | 2020-05-20 | 43.20 | 82155 | 0 |
| 9 | 2020-05-19 | 64.44 | 82155 | 0 |
| 10 | 2020-05-18 | 9.67 | 82155 | 0 |
+----+------------+--------------+------------+--------+
...
The value growth is supposed to be value that calculated by the system_value of adjacent time
for example
account_id 83266
1 the growth of date 2020-05-28 should be 0 as system_value of 2020-05-28 (18.34) is less than
2020-05-27 (30.63)
2 the growth of date 2020-05-27 should be 1 as system_value of 2020-05-27 (30.63) is more than
2020-05-26 (26.01)
3 the growth of date 2020-05-23 should be 1 as there's no value for 2020-05-22 (should be treated as 0)
4
My question is how can I do a Initial update for value growth for my table?
I'm using mysql5.7+
Thanks
Update
The growth is a value which is related with account_id and date, It's just an attribute for account at the date comparing with last day