I have 2 temp tables that are producing the following data
Tables A and B
If we focus only on RowID = 20 this will be easier.
I want to full outer join these rows on the following columns
A.RowID=B.B_RowID AND
A.fr_billto=B.B_fr_billto AND
A.ord_revtype2=B.B_ord_revtype2 AND
A.stp_mileagetype=B.B_stp_mileagetype AND
A.stp_type1=B.B_stp_type1 AND
A.BasisUnit=B.B_TARBasisUnit AND
A.RateUnit=B.B_RateUnit
The problem comes in during the last 2 conditions. For table B (row B_TARCode = ST) The data columns between A and B match until those last 2 conditions. Those columns in table B do not match the columns in table A, and are also not a NULL value, and because of this I am losing that “ST” record from table B.
What I would like to happen is that if there is a match on the first 5 columns (RowID, fr_billto, ord_revtype2, stp_mileagetype, stp_type1)… but then a non-null non-match on BasisUnit and RateUnit to still include those rows from table B.
Here is an example of what I am currently getting, and then what I am trying to end up with.
Current results, and results that I am after
Aaron Magewick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.