Questions tagged «running-total»

15
计算SQL Server中的运行总计
想象一下下表(称为TestTable): id somedate somevalue -- -------- --------- 45 01/Jan/09 3 23 08/Jan/09 5 12 02/Feb/09 0 77 14/Feb/09 7 39 20/Feb/09 34 33 02/Mar/09 6 我想要一个按日期顺序返回运行总计的查询,例如: id somedate somevalue runningtotal -- -------- --------- ------------ 45 01/Jan/09 3 3 23 08/Jan/09 5 8 12 02/Feb/09 0 8 77 14/Feb/09 7 15 …

9
在MySQL中创建累积总和列
我有一个看起来像这样的表: id count 1 100 2 50 3 10 我想添加一个新列,称为cumulative_sum,因此表如下所示: id count cumulative_sum 1 100 100 2 50 150 3 10 160 是否有可以轻松完成此操作的MySQL更新语句?做到这一点的最佳方法是什么?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.