创建临时表
select
convert(varchar,a.d,23) as [times]
from
(
select dateadd(day,number,'2022-04-01') as d from master..spt_values
where type='p'
and number >=0
and dateadd(day,number,'2022-04-01') between '2022-04-01' and dateadd(day,0,'2022-04-15')
) as a
order by times desc
效果

image.png
关联一个没有任何关系的表,实现每天数据统计
select
convert(varchar,a.d,23) as [times],
count(
case when convert(varchar,a.d,23) = convert(varchar,u.BaseCreateTime,23) then u.Id else null end
) as reg_nums
from
(
select dateadd(day,number,'2022-04-01') as d from master..spt_values
where type='p'
and number >=0
and dateadd(day,number,'2022-04-01') between '2022-04-01' and dateadd(day,0,'2022-04-15')
) as a
left join SysUser as u on 1=1
GROUP BY convert(varchar,a.d,23)
order by times desc
效果

image.png