Archives of the TeradataForum
Message Posted: Mon, 17 Dec 2012 @ 14:05:53 GMT
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!!
|Copyright 2016 - All Rights Reserved|
|Last Modified: 28 Jun 2020|