All Forums Database
tusharzaware1 25 posts Joined 02/13
21 Jan 2016
Date Setting

we have new requirement regarding date setting.
I am loading data for Jan, Feb,mar. In April I have to delete jam data and my table should contain only 3 months data.
i have handled this by using below delete query
delete from table name where report_date<add_months((date-extract(day from date)),-3)
Now consider I have missed data load for May,Jun,July . In Aug when I run my the end it will delete previous 3 months data. My requi is though I missed my data load it should keep last 3 run data. So in Aug it should keep Feb n March data also. But above query is deleting all data and keeping only Aug data.

Adeel Chaudhry 773 posts Joined 04/08
26 Jan 2016

Do you keep a log table which has the dates for which you have ran your load for?

-- If you are stuck at something .... consider it an opportunity to think anew.

You must sign in to leave a comment.