I have query where i want to change the SALES_DATE
to '01.01.2017
' for the 1st record for a product. It means i want to get every unique product which is stored in PRODUCT_ID
and check the first SALES_DATE
on which the product is loaded and change this SALES_DATE
to '01.01.2017
'.
I have used the below query which is working but its hitting the performance it seems. So is there any other i can write the same logic and improves the performance?
UPDATE TEST_GROUP sd
set SALES_DATE = TO_DATE ('01.01.2017', 'dd.mm.yyyy')
where SALES_DATE =
( select min(SALES_DATE)
from TEST_GROUP sd2
where sd.PRODUCT_ID = sd2.PRODUCT_ID
)
and sd.SALES_DATE <> TO_DATE ('01.01.2017', 'dd.mm.yyyy');