Gebruik een self-join:
SELECT
t1.ts,
t1.number,
t1.number - COALESCE(t2.number, t1.number) AS diff
FROM yourTable t1
LEFT JOIN yourTable t2
ON t1.id = t2.id + 1
ORDER BY
t1.ts;
Gebruik een self-join:
SELECT
t1.ts,
t1.number,
t1.number - COALESCE(t2.number, t1.number) AS diff
FROM yourTable t1
LEFT JOIN yourTable t2
ON t1.id = t2.id + 1
ORDER BY
t1.ts;