I have a sql that uses not exist, but I am doubtful on what column it is trying to match the Not Exist. Any help is highly appreciated, Thank You in advance.
from provider P
join clinic C on P.primary_ein = C.primary_ein
and C.source_type = 'PROV'
and (C.exp_date is null or C.exp_date >= GETDATE())
where P.cycle_id = 854 --1012
and P.provider_id is not null
and NOT exists
FROM health H
where P.provider_id = H.provider_id
and C.clinic_id = H.clinic_id
and H.staff_id is null)
The first column in health H table is an identity column 'Entity_id'.
Is the above query trying to see C.clinic_id that does on exist in H.EntityID list in the sub query?