UPDATE "Schema" SET varLid = 'S'
(SELECT pNumber, productName, varLid, MAX(dato) FROM "Schema"
WITH (index (SepOldTempIndex))
WHERE varLid = 'T'
GROUP BY pNumber, productName, varLid HAVING MAX(dato) <= '20010101') AS myData
WHERE myData.varLid = 'T'
The DB "Schema" can have more than 1,000,000 records,
We are using pervasive SQL.
All fields (varLid, pNumber, productName etc are strings)
Running the query "as is" means that it updates all records (not just within the select) in under 6 minutes.. (its only going to be run once). Adding more conditions ie: AND Schema.pNumber = myData.pNumber makes it run extrememly slow.
I need it to update only within the select. I can't using an alias on the UPDATE (pervasive won't allow it). Finaly.. just to make this even more interesting... the DB is VERY old and does NOT have any unique identifiers.
I would be MOST grateful with any suggestions.
Thankyou in advance.