The question's title might not be optimal.
What i'm trying to achieve is to retrieve company_id
from table site
where site has not been deleted. But, a company
has multiple site. I don't want to select a company that has one or more non-deleted website.
SELECT DISTINCT(company_id) FROM site WHERE _isDeleted = 1;
Gives me the companies which has a site deleted (8000+ results).
But when I try:
SELECT DISTINCT(company_id) FROM site WHERE _isDeleted = 1
AND company_id NOT IN (SELECT company_id FROM site WHERE _isDeleted = 0);
It gives me 0 results. Why ?
Performance is not at question there because it will be a run once policy query.