Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 14 Jan 2003 @ 23:19:40 GMT


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


Subj:   Re: History table monthend logic
 
From:   Sukesan, Ambili

Bruce,

I am not very clear on your requirement but a variation of the following SQL could work.

select acct_num,plan_code,plan_start_date,plan_end_dt
from plan_history
where plan_beg_dt <= '31-NOV-2002'  and
      plan_end_dt <= '31-NOV-2002'     /* this will give history before
NOV-31
      or pplan_end_dt = '9999-12-31'
                  /* this should give the transaction opened before
NOV-30 and still current */
qualify csum(1,acct_num,plan_code,plan_start_dt desc, plan_end_dt desc )
= group by acct_num,plan_code
/* If you want only the latest you would use a OLAP function to qualify
the latest */

Thanks

Ambili



     
  <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