time num
3:51 100
3:52 121
3:55 151
3:54 140
想结果变更为,即按 时间time 排序,后一个num减前一个num
time num
3:51 100
3:52 21 =>121-100
3:55 19 =>140-121
3:54 11 =>151-140
3:51 100
3:52 121
3:55 151
3:54 140
想结果变更为,即按 时间time 排序,后一个num减前一个num
time num
3:51 100
3:52 21 =>121-100
3:55 19 =>140-121
3:54 11 =>151-140
select a.time,max(b.num) as m from table1 a,table1 b where a.time>b.time group by a.time
) d
set c.num=c.num-d.m
where c.time=d.time