I am getting crazy !
I have a table like this:
Table TEST(
Date1 datetime,
Price float Null)
I fill the table with the days of the month.
And update the table with the right price for the day.
For some days, I do not have a price, and I want to get the price from the day before.
This sounds quite simple, I do not manage to find a solution !
This is (a selection of) what I already tried :
update TEST
set Price = t2.Price
from TEST t2
where Date1 = dateadd(dd,-1,t2.Date1)
and Price=NULL
=> nothing
update TEST
set Price = (select t2.Price from TEST t2 where Date1 = dateadd(dd,-1,t2.Date1))
where Price=NULL
=> Says one row was updated - but my table lokk the same !
Thank you !
I have a table like this:
Table TEST(
Date1 datetime,
Price float Null)
I fill the table with the days of the month.
And update the table with the right price for the day.
For some days, I do not have a price, and I want to get the price from the day before.
This sounds quite simple, I do not manage to find a solution !
This is (a selection of) what I already tried :
update TEST
set Price = t2.Price
from TEST t2
where Date1 = dateadd(dd,-1,t2.Date1)
and Price=NULL
=> nothing
update TEST
set Price = (select t2.Price from TEST t2 where Date1 = dateadd(dd,-1,t2.Date1))
where Price=NULL
=> Says one row was updated - but my table lokk the same !
Thank you !