【发布时间】:2018-09-21 10:25:32
【问题描述】:
我需要按月获取过去 12 个月的汇总数据,其中特定标准小于或等于每个月的最后一天。我从以前的员工那里继承了这份报告,该报告仅由每个月的此类脚本的工会组成:
select '2017_11' as 'Period', AccountId
from crm_account
where
ntw_StartedOnBoardingDate<=Timestamp('2017-11-30') and
(ntw_ChangedToLiveOn>Timestamp('2017-11-30') OR ntw_ChangedToLiveOn is null) and
(ntw_DisabledOn>Timestamp('2017-11-30') OR ntw_DisabledOn is null) and
statecode=0
问题是我怎样才能做到动态,因此它不会获取特定月份的信息,而是获取date_add(current_timestamp(), -12, 'month') 的信息。
谢谢!
【问题讨论】:
-
您能添加一些示例输入和相应的输出吗?
标签: date google-bigquery