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:
deposit
,开发者_如何学编程withdraw
,monthly interest paid
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,
};
精彩评论