Perhaps there are some NULLs in the sub-SELECT's result? See the archives concerning the not-very-intuitive behavior of NOT IN with NULL. regards, tom lane
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных