当前位置:网站首页>sql server如何得到本条记录与上一条记录的差异,即变动值
sql server如何得到本条记录与上一条记录的差异,即变动值
2022-08-04 05:14:00 【CSDN问答】
工具:sql server 2008 r2
如何得到本条记录与上一条记录的差异,即变动值,如图表table:

流水号 姓名 日期 持股数
1001 张三 2022/3/31 10000
1001 张三 2022/1/10 15000
1001 张三 2021/12/31 20000
1001 张三 2021/9/30 10000
1001 张三 2021/9/29 8000
1001 张三 2021/6/30 10000
1001 张三 2021/3/31 15000
1001 张三 2020/12/31 20000
希望得到如下结果:
流水号 姓名 日期 持股数 变动
1001 张三 2022/3/31 10000 -5000
1001 张三 2022/1/10 15000 -5000
1001 张三 2021/12/31 20000 10000
1001 张三 2021/9/30 10000 2000
1001 张三 2021/9/29 8000 -2000
1001 张三 2021/6/30 10000 -5000
1001 张三 2021/3/31 15000 -5000
1001 张三 2020/12/31 20000 0
谢谢!
边栏推荐
- C专家编程 第5章 对链接的思考 5.1 函数库、链接和载入
- el-Select 选择器 底部固定
- C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.3 什么是声明,什么是定义
- day13--postman接口测试
- 如何打造一篇优秀的简历
- 深度学习21天——卷积神经网络(CNN):实现mnist手写数字识别(第1天)
- el-Select selector bottom fixed
- 在被面试官说了无数次后,终于潜下心来整理了一下JVM的类加载器
- C Expert Programming Chapter 5 Thinking about Chaining 5.6 Take it easy --- see who's talking: take the Turning quiz
- Introduction and application of go module
猜你喜欢
随机推荐
Basic characteristics of TL431 and oscillator circuit
3000 words, is take you understand machine learning!
Cache pool of unity framework
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
触觉智能分享-SSD20X实现升级显示进度条
[Cocos 3.5.2]开启模型合批
Interesting Kotlin 0x0E: DeepRecursiveFunction
The difference between px, em, and rem
ADC噪声全面分析 -03- 利用噪声分析进行实际设计
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.4 使声明与定义相匹配
JVM笔记
文献管理工具 | Zotero
[C language advanced] program environment and preprocessing
Converts XML tags to TXT format (voc conversion for yolo convenient training)
leetcode 12. 整数转罗马数字
The 2022 PMP exam has been delayed, should we be happy or worried?
Towards Real-Time Multi-Object Tracking(JDE)
Introduction and application of go module
[Evaluation model] Topsis method (pros and cons distance method)
Performance testing with Loadrunner





![[C language advanced] program environment and preprocessing](/img/ac/a13dd2cc47136d4938b6fc7fad660c.png)



