While NOT IN
can be far more efficient than NOT EXISTS
in a query, it may return misleading results if the column in
question contains null values.
Noncompliant code example
SELECT COUNT(*) FROM emp
WHERE empno NOT IN ( SELECT mgr FROM emp );
Compliant solution
SELECT COUNT(*) FROM emp T1
WHERE NOT EXISTS ( SELECT NULL FROM emp T2 WHERE t2.mgr = t1.empno );