0
所以我创建了从事务表与所有客户购买记录有如下的表:如何通过案例不存在teradata?
- 月 - 年,
- 客户ID,
- 交易数在那个月。
我试图创建具有的1输出月 - 年表,2 当月定义为客户数目流失的客户中谁没有过交易在过去的12个月里。 (因此,如果客户在2014年1月仅进行一次购买,则客户将在2015年2月发生流失。
如果此人在2015年3月有交易,但直到2016年5月都没有交易,那么他们在4月份再次激活2016)。
我希望这里有任何建议。
的代码我作出SQL
作品,但不Teradata
:
select
month_start_date,
(select 1
from merchantengagement1 t2
where
t2.month_start_date >= t.month_start_date - INTERVAL '1' YEAR and
t2.month_start_date < t.month_start_date and
transactions > 0 and
t.rcvr_ID = t2.rcvr_ID
) then 1 else 0 end) as churnedCustomers
from
merchantengagement1 t
group by month_start_date