Are you wanting to do it in MySQL or Node Red? It's probably easier in NR by just storing the previous values in the flow context (assuming you have enabled persistent context), and then calculating it before you insert the new row into MySQL.
If you're wanting to do it in MySQL you would have to join the table to itself to get the previous entry. Something along the lines of:
select current.value - previous.value
from mytable as current
inner join mytable as previous on previous.ID =
where mytable.Device = current.Device
and mytable.timestamp < current.timestamp
order by mytable.timestamp desc