I have two temp tables
#tmpTableDates
(BusDate datetime)
#tmpTablePrices
(Code int (PK)
Busdate datetime,
Prices decimal(28, 8)
)
If I do not find the prices for a given date I have to use the previous days prices.
I get all the codes between the lowest date and the highest date.
In this example lowest date is 05/01/2013 and highest is 07/05/2013
Also the minimum date can have null values since there is nothing to go back to
I only need to return dates that I asked for and the relevant prices.
Lets say the data is as follow
#tmpTableDates
05/01/2013
06/01/2013
07/05/2013
#tmpTablePrices
Code 1 , 05/31/2013 , 5
Code 1, 07/01/2013, 3
Code 1 , 07/05/2013 , 2
My final result set should look like this, as 06/01 has no prices, take the previous days price.
Code 1 , 05/01/2013, NULL
Code 1 , 06/01/2013, 5
Code 1 , 07/05/2013, 2
Our community of experts have been thoroughly vetted for their expertise and industry experience.