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.
| 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, price1. how to calculate return with the following formula:return=log P(t)-log P(t-1), where P(t) is price attime t say day 1 and P(t-1) is price at one periodprevious t say day 0?RegardsCharly" |
|
|
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... |
 |
|
|
|
|
|
|
|