The following query runs really slow.
I have tryed different solutions like using #temp tables, not using the distinct keyword but the performance did not improve by much. What can I do to improve the performance of this query.
ENTITY IN ('BL', 'CA', 'CC', 'RC')
BATCH_ID NOT IN