自己参加を使用する:
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;
自己参加を使用する:
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;