Sorry for the title, not easy to phrase it correctly.
I have a table A which has a business key (Akey) with possible value range : k1, k2 and k3
AKey ACol2 ACol3
k1 val12 val13
k2 val22 val23
k3 val32 val33
I have a table B which has entries like
BKey1 BKey2 BKey3 AKey Col5 Col6
kk11 kk12 kk13 k1 val15 val16
kk21 kk22 kk23 k3 val25 val26
BKey1, BKey2 and Bkey3 is the business key of table B
Akey is a foreign key to table A
I would like to generate a result set with table B joined with table A (on AKey) but include “empty” lines for non referenced key from table A (and this for each key of table B). In the example I would like to have :
BKey1 BKey2 BKey3 AKey Col5 Col6 ACol2 ACol3
kk11 kk12 kk13 k1 val15 val16 val12 val13
kk21 kk22 kk23 k3 val25 val26 val32 val33
kk11 kk12 kk13 k2 def def val22 val23
kk11 kk12 kk13 k3 def def val32 val33
kk21 kk22 kk23 k1 def def val12 val13
kk21 kk22 kk23 k2 def def val22 val23
I have two entries just like for the inner join + entries for all other key range values of A (k1, k2 and k3) with default values (that I need to set) for columns of B. I tried a right join but then I only have default entries once in the result and not for each key of B. Can you help me in the right direction to achieve this ?
Christian
For test:
Result:
Test it here.