Tout d'abord, vous devez générer les dates. Ensuite, vous pouvez générer toutes les combinaisons de date et de nom. Enfin, remplissez les valeurs. Voici un exemple utilisant cross apply
:
with dates as (
select @MINDATE as thedate
union all
select dateadd(day, 1, thedate)
from dates
where dateadd(day, 1, thedate) <= getdate()
)
select thedate, vals.val
from dates cross join
(select distinct name from hypothetical) h cross apply
(select top 1 val
from hypothetical h2
where h2.name = h.name and h2.date <= dates.thedate
order by date desc
) vals;