First query returns no data because of comparing null values. When you compare 2 values result could be
TRUE
if they equalsFALSE
if they're notUNKNOWN
if one or two of the values is null
So when you use not in
sql should compare your value glnfact
with all values of GLN
in the subquery and if all compares return FALSE
, then it returns TRUE
for the whole not in
clause. If one of the value of GLN
is null, comparing it with glnfact
returns UNKNOWN
so not in
clause is UNKNOWN
.