我是Snowflake SQL的新手,正在编写获取历史仪表板的需求。
要求是从当前数据中获得5年的数据+希望包括过去5年的整个第一个月。例如,如果今天是2021年5月26日,我们需要从2016年5月1日至2021年5月25日。
使用我现在的Snowflake SQL查询,我得到了过去5年的数据,是否可以在Snowflak内置中获得剩余天数的增量。
select * from table where portion_start >= trunc(add_months(sysdate(),-12*5),'YEAR')
我相信这就是您想要的:
select *
from table
where portion_start >= dateadd(year,-5,date_trunc(month,current_date()))