使用运行总计更新表列. [英] Updating Table Column with Running Total.

查看:71
本文介绍了使用运行总计更新表列.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,
我正在SQLServer中维护具有以下详细信息的表.

-----------------------现金簿(LEDGER)----------------------
日期....说明...借项....信用.........余额
2011年1月1日..现金余额......................................... ... 5000
1/1/2011 ..销售.... 3000 ................................. ....... 8000
2011年1月1日..店铺租金......................... 2500 .5500
2/1/2011..Sales ................ 5000 ...................... ..... 10500
2/1/2011 ..购买.................. 5500 ........... ..5000
3/1/2011..Sales ................ 2000 .................................. ....... 7000

假设如果我使用SQL Update命令这样做,那么它只能更新特定的字段/列,但我希望BALANCE列的更新与RUNNING TOTAL方法相同...
在我的应用程序中,我使用Datagridview Windows Form Visual Basic 2010插入记录(DATE,DESCRIPTION,DEBIT,CREDIT),但必须更新余额列.

谢谢...

MIQUASH.

Dear Sir,
I''m maintaining a Table in SQLServer with following details.

-----------------------CASH BOOK (LEDGER)----------------------
DATE.......DESCRIPTION......DEBIT..........CREDIT.........BALANCE
1/1/2011..Cash Balance............................................5000
1/1/2011..Sales................3000................................8000
1/1/2011..Shop Rent.............................2500............5500
2/1/2011..Sales................5000..............................10500
2/1/2011..Purchase..............................5500.............5000
3/1/2011..Sales................2000................................7000

Suppose if I use SQL Update command to do so, it could update only particular field/column but I want BALANCE column to be updated same as RUNNING TOTAL method...
In my application I''m using Datagridview Windows Form Visual Basic 2010 to insert records (DATE,DESCRIPTION,DEBIT,CREDIT) but the balance column has to updated.

Thanking you...

MIQUASH.

推荐答案

据我所知,不要在数据库中使用Balance Column,而是必须在绑定到DataGridView时计算Balance.我在php中有示例代码,可以在vb.net中使用相同的内容

Hi, as per my knowledge, don''t take Balance Column in database, instead u have to calculate Balance when u r binding to DataGridView. i have sample code in php u can use same thing in vb.net

if(


row [' credit' ]!= 0){
row['credit']!=0){


余额 =
balance =


这篇关于使用运行总计更新表列.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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