Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 28 Jun 2007 @ 11:30:49 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


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



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023