Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Join a table without increasing lines, but columns instead

Hello,

I have these 2 tables and would like to obtain the result table.

Table1:
IDName
1A
2B
3C

Table2:
IDCompanyField1
11000X
12000Y
21000X
22000Z
32000Y

Result:
IDNameComp.1000Comp.2000
1AXY
2BXZ
3CY

I hope anyone can help. Thanks

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try:

Result:

load ID, Name

from ...table1source...;

join

Load ID, Field1 as Comp1000

from ...table2source...

where Company = 1000;

join

Load ID, Field1 as Comp2000

from ...table2source...

where Company = 2000;


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

Try:

Result:

load ID, Name

from ...table1source...;

join

Load ID, Field1 as Comp1000

from ...table2source...

where Company = 1000;

join

Load ID, Field1 as Comp2000

from ...table2source...

where Company = 2000;


talk is cheap, supply exceeds demand
Not applicable
Author

try to use generic load

*************************************

try this

Table1:

load * Inline [

ID,    Name

1,    A

2,    B

3,    C

];

join

Table2:

load * Inline [

ID,    Company,    Field1

1,    1000,    X

1,    2000,    Y

2,    1000,    X

2,    2000,    Z

3,    2000,    Y

];

Generic LOAD ID,'Comp.' & Company ,Field1 Resident Table1;

Generic LOAD ID,'Comp.' &Company ,Field1 Resident Table1;

er_mohit
Master II
Master II

see the attached file

output like this

IDNameComp1000Comp2000
1AXY
2BXZ
3C-Y