By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
with t as (
select convert(date, '2019-05-04') as dte, 16128.00 as amount union all
select '2019-05-06', 527008.00 union all
select '2019-05-07', 407608.00 union all
select '2019-05-10', 407608.00
)
select t.*
into t
from t
4 rows affected
with cte as (
select min(t.dte) as dte, max(t.dte) as maxdate
from t
union all
select dateadd(day, 1, dte), maxdate
from cte
where dte < maxdate
)
select cte.dte, coalesce(t.amount, 0) as amount
from cte left join
t
on cte.dte = t.dte
dte | amount |
---|---|
04/05/2019 00:00:00 | 16128.00 |
05/05/2019 00:00:00 | 0.00 |
06/05/2019 00:00:00 | 527008.00 |
07/05/2019 00:00:00 | 407608.00 |
08/05/2019 00:00:00 | 0.00 |
09/05/2019 00:00:00 | 0.00 |
10/05/2019 00:00:00 | 407608.00 |