I have a table with a lot of history entries that contain customer IDs.
There is a separate customer table. Occasionally some of the customer entries are removed.
DELETE FROM CUSTOMER_HISTORY CH WHERE NOT EXISTS (SELECT 1 FROM CUSTOMER C WHERE C.CUSTOMER_ID = CH.CUSTOMER_ID)