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 |
|
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2011-01-31 : 04:17:19
|
Hi,I need single query for this below scenario.Table:-code ---date ---- price -- calcufs_001 --- 01-01-2011 --- 10.5 -- fs_001 --- 02-01-2011 --- 11.5 --fs_001 --- 03-01-2011 --- 7.5 -- fs_001 --- 04-01-2011 -- 5.5 --fs_001 --- 05-01-2011 -- 4.5 --fs_001 --- 06-01-2011 -- 8.5 -- fs_001 --- 07-01-2011 --- 9.5 -- fs_001 --- 08-01-2011 -- 11.5 -- I need to find the calcu column values ?calculation part rules,**********************1. 1st pick the price values on year starting date,2. minus calcu = starting date price - previous date price value3. check where condition wil be comparing the given dates..i.e.,*****calcu = 11.5 - 10.5 ( 02-01-2011 price value - 01-01-2011 price value) its give the calcu value.I need single statement for this scenario..suggestion welcome..MAG,Start with the new Idea.. http://mageshkumarm.blogspot.com/ |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-01-31 : 05:23:18
|
| Look up the term "running total". You will find many examples that shows you how to solve this problem.- LumbagoMy blog-> www.thefirstsql.com |
 |
|
|
|
|
|