I have a table as below:
CREATE TABLE product
(
PRODUCT NVARCHAR2(20) NOT NULL,
TYPE NUMBER(5) NOT NULL,
ID NUMBER(10) NOT NULL,
addDATE DATE NOT NULL,
TITLE NVARCHAR2(80) NOT NULL
)
I have to delete records from the table based on the column type and addDate. There are 40 types of products and each product has a different deletion criteria. Below is the query I am currently using;
DELETE from PRODUCT where
(type =1 and trunc(ADDdate) < add_months( sysdate, -24 ))
OR
(type =2 and trunc(ADDdate) < add_months( sysdate, -12 ))
OR
(type =3 and trunc(ADDdate) < add_months( sysdate, 12 ))
.
..
.
.
OR
(type =49 and trunc(ADDdate) < add_months( sysdate, 1 ));
Could you please suggest me an efficient way of implement this other than the above mentioned query.