I had a table with n days of data.I need to delete last 35 days of data.My table doesnt have consecutive dates i.e. there were no loads in weekends or holidays..
Using INTERVAL command may just calculate the difference.So it wont work out.
I can use RANK to find the sequence.Is there any other better way to write a delete statement.
This should work for you,
DEL FROM db.tb WHERE t_Date IN
(SEL t_date FROM
( SEL t_date, RANK(t_date) RD FROM (SEL t_date FROM db.tb GROUP BY 1) D ) D2
WHERE RD <= 25)