I have data date
and a
in this table my table
How I can get b
where the value is a subtract by a
from previous date
?
Advertisement
Answer
You may use the LAG
analytic function here:
SELECT date, a, a - LAG(a) OVER (ORDER BY date) AS b FROM yourTable ORDER BY date;