Hi,
I have a table "TBL_DATA_RISICO_PROFIEL" of which I want to delete old records (meaning older than the most recent timestamp of every forecast in the table).
There are 5 companies, so I have made a Max query on that same table ("TBL_DATA_RISICO_PROFIEL") that shows all the most recent time stamps per forecast per company.
I was hoping that I could create a delete query and delete all records that not show any value if I left join these three fields. However that does not work.
Is there anyone with a suggestion how to delete the older records with a joined table like this?
Code until now:
Code:
DELETE TBL_DATA_RISICO_PROFIEL.*, TIMESTAMP_MAX.COMPANYFROM TBL_DATA_RISICO_PROFIEL LEFT JOIN TIMESTAMP_MAX ON (TBL_DATA_RISICO_PROFIEL.TIMESTAMP = TIMESTAMP_MAX.MaxOfTIMESTAMP) AND (TBL_DATA_RISICO_PROFIEL.FORECAST = TIMESTAMP_MAX.FORECAST) AND (TBL_DATA_RISICO_PROFIEL.COMPANY = TIMESTAMP_MAX.COMPANY)
WHERE (((TIMESTAMP_MAX.COMPANY) Is Null));
Many thanks so far,
Michiel