Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 17 Dec 2012 @ 14:05:53 GMT


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


Subj:   Re: Delete query based on target table date
 
From:   Jepamony, Johnpaul

Excellent Dave!!

Your query works perfect however I require this delete script on mload so I proceed with below subquery as I cannot create a volatile table.

     DELETE FROM TABLE
     WHERE cal_dt <
     (
     SELECT MIN(a.cal_dt)
     FROM (
     SELECT TOP 4 cal_dt
     FROM TABLE
     GROUP BY cal_dt
     ORDER BY cal_dt DESC) a );

Above query holds exactly last four weeks of data. Thanks a lot for your help!!


Regards,

John



     
  <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