|
|
Archives of the TeradataForum
Message Posted: Thu, 28 Jun 2007 @ 11:30:49 GMT
Subj: | | Re: Total payment volume per transaction per customer |
|
From: | | Vinay Bagare |
Check if this helps
SEL
Uid
,TransDate
,Amt
,MAX(TransDate) OVER(PARTITION BY Uid ORDER BY TransDate DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
- TransDate AS DateDiff
,CASE WHEN DateDiff <30
THEN SUM(Amt) OVER(PARTITION BY Uid ORDER BY TransDate DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
ELSE NULL END AS RollingSum
FROM TEST
QUALIFY RollingSum IS NOT NULL
ORDER BY 2 DESC;
Thanks,
Vinay Bagare
| |