M
MJatAflac
Someone sent me this sql and asked me to try to find an answer for him. He
runs the query twice once saying where field a equals field b and once where
field a is not equal to field b. I would expect that the total records from
each run would add up to the same number as taking the criteria out all
together. This is not true and by a process of elimination we determined that
the records falling out where field b is null.
Can anyone explain that? Thanks All!
SELECT DISTINCT dbo_axiom_flex_gm.duns,
dbo_axiom_flex_gm.gm_srce_group_name, dbo_axiom_flex_gm.gm_group_nbr,
dbo_axiom_flex_gm.fl_group_nbr, dbo_axiom_flex_gm.fl_flex_id,
dbo_axiom_flex_gm.fl_srce_group_name, dbo_axiom_flex_gm.gm_acc1_nm,
dbo_axiom_flex_gm.gm_acc2_nm, dbo_axiom_flex_gm.gm_srce_tin,
dbo_axiom_flex_gm.fl_srce_tin, dbo_axiom_flex_gm.gm_tin
FROM [Distinct Group Numbers - Col] INNER JOIN dbo_axiom_flex_gm ON
[Distinct Group Numbers - Col].gm_group_nbr = dbo_axiom_flex_gm.gm_group_nbr
WHERE (((dbo_axiom_flex_gm.gm_group_nbr)=[dbo_axiom_flex_gm]![fl_group_nbr])
AND ((dbo_axiom_flex_gm.gm_srce_tin)<>[dbo_axiom_flex_gm]![fl_srce_tin] And
(dbo_axiom_flex_gm.gm_srce_tin)<>" ") AND
((dbo_axiom_flex_gm.fl_srce_tin)=[gm_tin])) OR
(((dbo_axiom_flex_gm.gm_group_nbr)=[dbo_axiom_flex_gm]![fl_group_nbr]) AND
((dbo_axiom_flex_gm.gm_srce_tin)<>[dbo_axiom_flex_gm]![fl_srce_tin] And
(dbo_axiom_flex_gm.gm_srce_tin)<>" ") AND ((dbo_axiom_flex_gm.gm_tin)
Is Null))
ORDER BY dbo_axiom_flex_gm.gm_srce_tin;
runs the query twice once saying where field a equals field b and once where
field a is not equal to field b. I would expect that the total records from
each run would add up to the same number as taking the criteria out all
together. This is not true and by a process of elimination we determined that
the records falling out where field b is null.
Can anyone explain that? Thanks All!
SELECT DISTINCT dbo_axiom_flex_gm.duns,
dbo_axiom_flex_gm.gm_srce_group_name, dbo_axiom_flex_gm.gm_group_nbr,
dbo_axiom_flex_gm.fl_group_nbr, dbo_axiom_flex_gm.fl_flex_id,
dbo_axiom_flex_gm.fl_srce_group_name, dbo_axiom_flex_gm.gm_acc1_nm,
dbo_axiom_flex_gm.gm_acc2_nm, dbo_axiom_flex_gm.gm_srce_tin,
dbo_axiom_flex_gm.fl_srce_tin, dbo_axiom_flex_gm.gm_tin
FROM [Distinct Group Numbers - Col] INNER JOIN dbo_axiom_flex_gm ON
[Distinct Group Numbers - Col].gm_group_nbr = dbo_axiom_flex_gm.gm_group_nbr
WHERE (((dbo_axiom_flex_gm.gm_group_nbr)=[dbo_axiom_flex_gm]![fl_group_nbr])
AND ((dbo_axiom_flex_gm.gm_srce_tin)<>[dbo_axiom_flex_gm]![fl_srce_tin] And
(dbo_axiom_flex_gm.gm_srce_tin)<>" ") AND
((dbo_axiom_flex_gm.fl_srce_tin)=[gm_tin])) OR
(((dbo_axiom_flex_gm.gm_group_nbr)=[dbo_axiom_flex_gm]![fl_group_nbr]) AND
((dbo_axiom_flex_gm.gm_srce_tin)<>[dbo_axiom_flex_gm]![fl_srce_tin] And
(dbo_axiom_flex_gm.gm_srce_tin)<>" ") AND ((dbo_axiom_flex_gm.gm_tin)
Is Null))
ORDER BY dbo_axiom_flex_gm.gm_srce_tin;