Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm having difficulty joining table 2 to table 1. I've tried a left join but the final table results in duplicate IDs and I'm not sure why. Table 1 has many more different Codes than Table 2.
Table 1: (has more columns than this)
ID | Code |
---|---|
1 | 11 |
2 | 12 |
3 | 13 |
4 | 14 |
5 | 15 |
6 | 16 |
7 | 17 |
8 | 18 |
9 | 19 |
10 | 20 |
11 | 21 |
Table 2:
Code | Type | Description |
---|---|---|
11 | A | xyz11 |
18 | B | xyz12 |
19 | C | xyz13 |
21 | D | xyz13 |
Desired resulting table:
ID | Code | Type | Description |
---|---|---|---|
1 | 11 | A | |
2 | 12 | xyz11 | |
3 | 13 | ||
4 | 14 | ||
5 | 15 | ||
6 | 16 | ||
7 | 17 | ||
8 | 18 | B | xyz12 |
9 | 19 | C | xyz13 |
10 | 20 | ||
11 | 21 | D | xyz14 |
I would use ApplyMap. Maybe something like this :
MapType :
Mapping
LOAD
Code,
Type
FROM [lib://289355]
(html, codepage is 28591, embedded labels, table is @2);
MapDecription :
Mapping
LOAD
Code,
Description
FROM [lib://289355]
(html, codepage is 28591, embedded labels, table is @2);
Data :
LOAD
ApplyMap ( 'MapType' , Code , null() ) as Type ,
ApplyMap ( 'MapDecription' , Code , null() ) as Description ,
ID,
Code
FROM [lib://289355]
(html, codepage is 28591, embedded labels, table is @1);
See attached qvf,