select date_add('2021-01-01',interval @i:=@i+1 day) as date
from ( select 1 union all select 1 union all select 1 union all select 1) as tmp,
(select @i:= -1) t
本文介绍了一种使用SQL生成连续日期的方法。通过自连接的方式创建了一个包含连续日期的数据集,适用于需要按天填充数据或者进行时间序列分析的场景。此方法简单高效,易于理解和实现。
select date_add('2021-01-01',interval @i:=@i+1 day) as date
from ( select 1 union all select 1 union all select 1 union all select 1) as tmp,
(select @i:= -1) t
3713

被折叠的 条评论
为什么被折叠?