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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -