Mysql – Time addition based on the previous row

MySQLmysql-5.7

I appreciate if someone could give me some help.
I would like to deal with time addition based on the previous column using mysql. Here is what I have.

create temporary table test(id integer, 
                            realtime datetime, 
                            realminute float(15));

insert into test(id, realtime, realminute) values
("1","2018-12-12 03:03:03","96");

insert into test(id, realminute) values
("2","15"),
("3","10"),
("4","30"),
("5","30"),
("6","15");

Then I have this.

id|          realtime                      | realminute
1|           2018-12-12 03:03:03           |  96
2|                                         |  15
3|                                         |  10
4|                                         |  30
5|                                         |  30
6|                                         |  15

The following is what I would like to have. Note that 2018-12-12 03:03:03 plus 96 minutes would be 2018-12-12 04:39:03. This would be the realtime in the second column. And 2018-12-12 04:39:03 plus 15 minutes would be 2018-12-12 04:54:03 and this would be the real time in the third column and so on.

id|          realtime  | realminute
1| 2018-12-12 03:03:03 |  96
2| 2018-12-12 04:39:03 |  15
3| 2018-12-12 04:54:03 |  10
4| 2018-12-12 05:04:03 |  30
5| 2018-12-12 05:34:03 |  30
6| 2018-12-12 06:04:03 |  15

How would I calculate these realtime values?

Best Answer

I think I found the answer. The following code works.

select @realtime,
@realtime := date_add(@realtime, interval realminute minute) as j, t.*
from test as t, (select @realtime := "2018-12-12 03:03:03") a
order by id asc;