开发者

calculate the balance of all rows

What I am trying to do here is to calculate the balance of all rows in my transaction table that have fields relating to the following:

From these, I then calculate at the end of rows the balance using this code:

select transaction_Id, o.amount_deposited, o.amount_withdraw, o.Interest_recived,
    (select (sum(amount_deposited) - o.amount_withdraw + (o.Interest_recived))
    from transactionn where transaction_Id <= o.transaction_Id)
      'Balance'
    from transactionn o

However, the output is not as I wanted.


Your question isn't very clear and you've also tagged the question as "linq" but you have a SQL query.

My best guess, at this point in time, is this (assuming LINQ):

var ts = from o in transactionn
         select new
         {
             o.transaction_Id,
             o.amount_deposited,
             o.amount_withdraw,
             o.Interest_recived,
             Balance = o.amount_deposited - o.amount_withdraw + o.Interest_recived,
         };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜