Let's say I have a table of parts that were on a shipment and parts that were on a receipt. I want to match up what I shipped compared to what I received, bound together by a common Shipment Number.
Shipment Table
SHIPMENT NO PART NO
1 A
1 B
2 A
2 C
Receipt Table
SHIPMENT NO PART NO
1 A
1 C
2 B
3 A
Desired Results
SHIP. SHIP. NO SHIP. PART NO RPT. SHIP. NO RPT. PART NO
1 A 1 A
1 B 1 NULL
1 NULL 1 C
2 A 2 NULL
2 NULL 2 C
NULL NULL 3 A
So the idea would be that there is a full outer join showing all distinct shipment numbers and respective part numbers for both shipments and receipts, but joining them together where they match. The complication is still joining on the Shipment No even if the part numbers don't match.
There are basically two join conditions, one of which is completely optional.
I'm certain the solution is very simple but I can't see how to do this without using unions.