Użyj samodzielnego łączenia:
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;
Użyj samodzielnego łączenia:
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;