0
说我有下表。如果我的连接表与日期和货币不匹配,我如何获取以前的最新值?在空DKK值,我希望它拿起3.请注意,日期不是每天都存在,因为我没有在周末加载表。用最新值替换空值
Select
PositionDate,
Currency,
T2.Value,
isnull(t2.value, ?)
From t1
left join t2
on t1.currency = t2.Currency
and t1.PositionDate = t2.PositionDate
。
PositionDate Currency Value
2017-04-11 SEK 1
2017-04-11 DKK NULL
2017-04-11 EUR 7
2017-04-10 SEK 4
2017-04-10 DKK 3
2017-04-10 EUR 5
2017-04-07 SEK 4
2017-04-07 DKK 3
2017-04-07 EUR 5
。