Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
i have a situation like this:
Table 1:
Key1 |
---|
11 |
22 |
33 |
44 |
Table 2:
Key2 | Key1 |
---|---|
A | 11 |
B | 11 |
C | 22 |
D | 33 |
E | 44 |
I need to load Table 1 with a summary of the keys on Table 2:
Key1 | Summary Key2 |
---|---|
11 | A;B |
22 | C |
33 | D |
44 | E |
Which is the best option?
Many thanks
Try this:
Table2:
Load * INLINE [
Key1, Key2
11, A
11, B
22, C
33, D
44, E
];
Table1:
NoConcatenate
Load * Inline [
Key1
11,
22,
33,
44
];
Table3:
NoConcatenate
LOAD Distinct
Concat(DISTINCT Key2, '; ') As [Summary Key2],
Key1
Resident Table2
Group by Key1;
Load Key1 from table1;
left join
Load Key1, concat(Key2) from Table2;
Hope it helps
Concat() function is what you need:
result:
LOAD
Key1,
concat(Key2, ';') as "Summary of Key2"
FROM table2
GROUP BY Key1;
Try this:
Table2:
Load * INLINE [
Key1, Key2
11, A
11, B
22, C
33, D
44, E
];
Table1:
NoConcatenate
Load * Inline [
Key1
11,
22,
33,
44
];
Table3:
NoConcatenate
LOAD Distinct
Concat(DISTINCT Key2, '; ') As [Summary Key2],
Key1
Resident Table2
Group by Key1;