Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 cumulative addition

Author  Topic 

sfunds
Starting Member

7 Posts

Posted - 2006-01-28 : 09:15:19
Hi,
I have following data struc

Table name TradeAccount

id char(10) ,
trn_date datetime,
type int,
amount

Required

there are 25 types

I want trn_date , amount , cumulative sum of amount
order by trn_date

I cannot use id for query
How to achieve it.


Next also I want to get difference between amounts
between two consecutive rows and between two dates ie

trn_date amount diffdate diffamount

1/1/2006 10000 - -
10/1/2006 20000 10 10000
20/1/2006 30000 10 10000
20/1/2006 35000 0 5000


is it possible thanks
sfunds@yahoo.com

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2006-01-28 : 12:07:22
Hi,
See if this helps..
select trn_date , sum(amount)
from TradeAccount
group by trn_date

else Post some data
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-28 : 19:16:20
Use shallu1_gupta's code to get the sum(amount) by trn_date. Use your front-end application to obtain the cumulative sum and difference.

----------------------------------
'KH'

I come I saw I post
Go to Top of Page
   

- Advertisement -