如何根据上述值增加表值。 [英] How do I increase the table values based the above values.

查看:114
本文介绍了如何根据上述值增加表值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请找到下面的sql server表格。



 COL A Col B 
1 1000
2 2000
3 1000
4 2000
$ 3000





i想要如下所示。它意味着 colb1,colb1 + colb2,col1 + col2 + col3 等。

 COL A Col B 
1 1000
2 3000
3 4000
4 6000
5 9000

解决方案

< blockquote>它被称为:运行总和 [ ^ ]



请参阅:

在SQL Server中计算简单运行总计 [ ^ ]

http ://stackoverflow.com/questions/14953294/how-to-get-running-sum-of-a-column-in-sql-server [ ^ ]

http://stackoverflow.com/questions/2120544/how-to-get-cumulative-sum [ ^ ]

你不想 - 因为下次尝试你会将第2行更新为4000,第3行更新为7000,依此类推。

相反,返回运行基于查询的总列:在SQL Server中计算简单运行总计 [ ^

Hi ,
please find the below sql server table table .

COL A	Col B
1	1000
2	2000
3	1000
4	2000
5	3000



i want out put like below . it means colb1,colb1+colb2,col1+col2+col3 etc.

COL A	Col B
1	1000
2	3000
3	4000
4	6000
5	9000

解决方案

It is called: running sum[^]

See:
Calculating simple running totals in SQL Server[^]
http://stackoverflow.com/questions/14953294/how-to-get-running-sum-of-a-column-in-sql-server[^]
http://stackoverflow.com/questions/2120544/how-to-get-cumulative-sum[^]


You don't want to - because next time to try you will update row 2 to 4000, row 3 to 7000, and so on.
Instead, return a running total column based on a query: Calculating simple running totals in SQL Server[^]


这篇关于如何根据上述值增加表值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆