繁体   English   中英

在雪花 sas 中的 2 个日期列之间进行过滤

[英]where filter between 2 date columns in snowflake sas

问题是我正在尝试引入 s_date 之后 4 天的 trdate

我正在使用 sas 并为标记为 A 列的雪花连接创建了一个临时表。我正在加入一个表列 b。 我的代码如下

create table post_date as select * from connection to snf(
select distinct
 A.*
, b. PA
, b. tc
, b. trdate
from stemptable as A
    left join table B
        on A.rp=b.PA
where a.s_date between b.trdate and 

我知道 b.trdate 上的某些内容必须为 +4,但不确定语法是否正确。

这就是我被困的地方。 我试图将 b.trdate 设置为 a.s_date 之后的 4 天。 任何援助将不胜感激。

如果您希望 trdate 在 s_date 之后 4 天,您需要 trdate = s_date + 4 天。 在 SQL 中,四天是添加到日期的间隔,如以下查询所示:

select
   s.*
 , b.pa
 , b.tc
 , b.trdate
from stemptable as s
left join table tr on tr.pa = s.rp
                  and tr.trdate = s.s_date + interval '4 days';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM