SQL服务器中的余额计数 [英] Balance count in SQL server

查看:181
本文介绍了SQL服务器中的余额计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我在计算余额方面遇到麻烦我正在做这样的事情我正在尝试选择记录然后计算余额。

表1

ID

名称

价值(金钱)

类型(in,Out)

表2

ID

StartBalance(这是常数,它的值是100)



soo当我选择表格时我需要制作临时列,其中每个都是平衡的表1的记录,必须看进出类型,例如:

表1

1 2

Peter Jhon

34 $ 20 $

IN Out



起始余额我知道这是100 $

所以这个选择必须如下:

1

Peter

34 $

IN

(temp Col Balance)= 134 $

下一条记录

2

Jhon

20 $

Out

(temp Col Balance)= 114 $

plz帮我做这个选择或某个程序为此



我尝试了什么:



i用Google搜索但找不到解决方案

Hello i have trouble in counting balance soo i am doing like this i am trying to select recoreds and then count balance.
Table1
ID
Name
Value(money)
Type(in, Out)
Table2
ID
StartBalance(this is constant and it's value 100)

soo when i am selecting table i need to make temporary column where will bee balance of each record of Table 1 and it must look on in and out Type for example:
Table 1
1 2
Peter Jhon
34$ 20$
IN Out

Starting balance i know that is 100$
so this select must look like:
1
Peter
34$
IN
(temp Col Balance)=134$
Next record
2
Jhon
20$
Out
(temp Col Balance)=114$
plz help me to do this select or some procedure for this

What I have tried:

i have googled it but can't find solution

推荐答案

20




IN Out



起始余额我知道是100

IN Out

Starting balance i know that is 100




所以这个选择必须如下:

1

彼得

34

so this select must look like:
1
Peter
34


这篇关于SQL服务器中的余额计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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