Conditional Join SQL Server -
i have scenario below:
source1
column1 column2
source2
column1 column2
output - need view;
all records in source1 column2 not empty must in view.
all records in source1 column2 empty must joined source2 (on column1, reference between both tables). wherever finds match column2 of source2 should included in view.
any pointers please..
the easiest way see union of both queries:
select * source1 column2 not null union select s2.* source1 s1 inner join source2 s2 on s1.column1 = s2.column1 s1.column2 null
Comments
Post a Comment