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)
 Re: help with calculating return

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-05-24 : 10:30:47
writes "Dear all,

I have 3 column: date, stocks name, price


1. how to calculate return with the following formula:
return=log P(t)-log P(t-1), where P(t) is price at
time t say day 1 and P(t-1) is price at one period
previous t say day 0?


Regards


Charly"

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-05-24 : 10:41:44
[code]
sum(case when dateadd(dd, datediff(dd,0,date), 0) = dateadd(dd, datediff(dd,0,getdate()), 0) then price else 0 end) - sum(case when dateadd(dd, datediff(dd,0,date), 0) = dateadd(d,-1,dateadd(dd, datediff(dd,0,getdate()), 0)) then price else 0 end) PriceDiff
[/code]
will give you the difference between the price today and yesterday...
Go to Top of Page
   

- Advertisement -