Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有数据date,a在这个表中我的表我 怎样才能得到从以前b的值减去的值?adate
date
a
b
您可以在LAG这里使用分析功能:
LAG
SELECT date, a, a - LAG(a) OVER (ORDER BY date) AS b FROM yourTable ORDER BY date;