Tuesday, 15 January 2013

SQL left join with filter not using the filter -



SQL left join with filter not using the filter -

in code snippet:

proc sql; create table test3 (id numeric (10)); create table test4 (id numeric (10)); quit; proc sql; insert test3 (id) values (1); insert test3 (id) values (2); insert test3 (id) values (2); insert test4 (id) values (1); insert test4 (id) values (2); create table test5 select * test3 left bring together test4 on test3.id = test4.id , test3.id<> 2 , test4.id <> 2; quit;

i trying rows test3 if there no matching rows on test4, provided value of id column <>2 in test3 , test4....a.k.a in final output, don't want id = 2 record, not once.

but above bring together giving:

1 2 2

as if <> 2 filter not there @ all. why this?

try:

create table test5 select * test3 left bring together test4 on test3.id = test4.id test3.id<> 2 , test4.id <> 2;

your bring together clause includes and creating union. alter where.

sql left-join

No comments:

Post a Comment