【发布时间】:2022-01-18 12:44:59
【问题描述】:
我想在 Redshift 中创建动态列,它将动态添加增加 1 的新值。基本上它会计算与特定日期的月份距离,比如 2020 年 1 月 1 日。所以本月应该是 23,下个月应该是 24 等等。是否有可能以某种方式替换我现在在 WITH 语句中拥有的静态内容?计数器在 12 停止,我必须每个月手动增加它。
with months as (
select 1 as mon union all select 2 union all select 3 union all select 4 union all
select 5 as mon union all select 6 union all select 7 union all select 8 union all
select 9 as mon union all select 10 union all select 11 union all select 12
),
【问题讨论】:
标签: sql amazon-redshift