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)
 Query to generate opposite of running total

Author  Topic 

sangeeta
Starting Member

16 Posts

Posted - 2005-12-06 : 00:51:24
Hi -

I am fairly new to SQL and need help in designing query for the following.

My data set in the table looks like this:

DATA
----
Symbol TradePrice Cumulative trades
MSFT 256 100
MSFT 260 50
AA 50.80 100
AA 50.80 150
MSFT 256 200
MSFT 256 350
AA 50.90 50
MSFT 260 150

The Trade quanity in the third column is a cumulative value - cumulated on each change in symbol and price. I am looking to get individual traded quantity where the result set would lokk like:

RESULT
------
Symbol TradePrice Cumulative trades
MSFT 256 100
MSFT 260 50
AA 50.80 100
AA 50.80 50
MSFT 256 100
MSFT 256 150
AA 50.90 50
MSFT 260 100

Thanks a TON

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-06 : 02:06:44
You should properly store the data. Why did you store cumulative data? Store values and use Reports to show the Running Total.

Apply the logic suggested by stoad
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=32521

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sangeeta
Starting Member

16 Posts

Posted - 2005-12-06 : 02:32:41
Thanks -

I did not create the data. This is how the data was captured by the system.

Thanks for your help.

Sangeeta
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-06 : 03:59:35
Refer this
http://sqlteam.com/forums/topic.asp?TOPIC_ID=58098

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -