Subject VERY strange problem with subquery and NOT IN
Author tomasz007
FB 1.0.2

subquery version A:
--------------------
select DK.KOMPLET_ID from
dokument_komplet DK join
dokument D on
DK.SYS_FILIA_ID = D.SYS_FILIA_ID AND
DK.DOKUMENT_ID = D.DOKUMENT_ID AND
D.DOKUMENT_TYP_ID in (4,3,11,1)
where dk.komplet_ID = 181016

0 row(s) fetched (0 row(s) listed).
Exec time: 8,29 s / Fetch time: 0,00 s

subquery version B:
--------------------
select DK.KOMPLET_ID from
dokument_komplet DK join
dokument D on
DK.SYS_FILIA_ID = D.SYS_FILIA_ID AND
DK.DOKUMENT_ID = D.DOKUMENT_ID AND
D.DOKUMENT_TYP_ID in (4,3,11,1)
where DK.SYS_FILIA_ID = 1 and dk.komplet_ID = 181016

0 row(s) fetched (0 row(s) listed).
Exec time: 0,01 s / Fetch time: 0,00 s

subquery version C:
--------------------
select DK.KOMPLET_ID from
dokument_komplet DK join
dokument D on
DK.SYS_FILIA_ID = D.SYS_FILIA_ID AND // this join
condition
DK.KONTRAHENT_ID = D.KONTRAHENT_ID and // covers the
whole
DK.KONTRAHENT_ADRES_ID = D.KONTRAHENT_ADRES_ID and // PK of DK
and
DK.DOKUMENT_ID = D.DOKUMENT_ID AND // FK between
DK and D
D.DOKUMENT_TYP_ID in (4,3,11,1)
where DK.SYS_FILIA_ID = 1 and dk.komplet_ID = 181016

0 row(s) fetched (0 row(s) listed).
Exec time: 0,26 s / Fetch time: 0,00 s

now, when I use the above subqueries in the below query:

select * from komplet where
komplet_ID = 181016 and
KOMPLET_ID not in (<subquery here>)

... I'm getting following results:

for subquery A: one record - correct
for subquery B: no records - not correct
for subquery C: one record - correct

Why the inconsistency if the subquery in ALL cases returns no records
if ran separately. Why the fact if I join by full PK/FK matters in
this case - it should not influence anything except execution time.

What am I missing?

Thanks, cheers,
Tomasz