Teradata经常性支付模式

时间:2016-08-25 04:03:50

标签: sql teradata

我正在使用客户期间级别数据来查找他们已完成的交易的重复模式。

我想要的是找出客户是否每周,每两周或每月定期支付+ -10%的金额。

我因此而被限制在Teradata,所以我使用同一个表来自联接,该表定义了事务进行的帐户和渠道的连接。由于频道可能会有所不同,因此一天内可能会有多个交易,因此需要加入过滤器。我也给了一个松散的窗口,因为人们可以在一天之后或之前付款。

我目前使用的查询是这样的:

`
create multiset table weekly as 
(
sel a.*, b.*, c.*
from table1 a
join table1 b
on a.account = b.account and a.channel = b.channel
join table1 c
on a.account = c.account and a.channel = c.channel
where c.date between b.date + 6 and b.date + 9 and b.amount between 0.9*(c.amount) and 1.1*(c.amount) 
and b.date between a.date + 6 and a.date + 9 and a.amount between 0.9*(b.amount) and 1.1*(b.amount)
)
with data
primary index(account)
'

还有其他有效的方法吗,因为我能够最大限度地加入3个自我加入,我需要超过3次重复来确认它的每周?我可以将这些数据迁移到R,然后在其上构建一些算法,但数据大小约为4000万。

0 个答案:

没有答案