I have table with following structure:
TestTable (ID INT, LoanID INT, Amount INT)
ID LoanID Amount
1 1 20
2 1 30
3 1 15
4 2 40
5 2 20
6 3 50
I want to calculate LoanAmounts with this scenario
ID LoanID Amount Sum
1 1 20 20
2 1 30 50
3 1 15 65
4 2 40 40
5 2 20 60
6 3 50 50
What is the best way to get this Sum collumn (Of course without cursor :))