【发布时间】:2021-03-02 23:11:16
【问题描述】:
此代码在 SSMS 中完美运行,但在 Snowflake 中却没有那么多。关于如何修复它的任何建议?
set (start_date) = ('2017-07-01');
set (end_date) = ('2022-06-30');
with get_all_dates as (
select
$start_date as DateValue
, 1 as level
union all
select
DATEADD(DAY,1,DateValue)
, level + 1
from
get_all_dates
where
Datevalue < $end_date
)
select * from get_all_dates;
这会产生以下错误消息:
SQL 编译错误:锚点和递归项之间的类型不匹配 递归 CTE 'GET_ALL_DATES' 中的列 'DATEVALUE'
预期输出:
2017-07-01
2017-07-02
...
2022-06-29
2022-06-30
【问题讨论】:
标签: sql snowflake-cloud-data-platform