Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Theo_Westseit
Contributor III
Contributor III

Join two Tables into master table

Hello Guys,

im trying to join two Tabels (Table A and B) into one master table.
How to join these tables?

The scripts look likes this:

Master Table:

Master_Temp:
LOAD
FieldA As Name,
FieldB As Date,
FieldC As Hours-Category,
If(FieldC=’A’,FieldD) As A,
If(FieldC='B',FieldD) As B,
If FieldC='C',FieldD) As C,

FROM [lib://DATA_Public/EXPORT.csv]
(txt, codepage is 28591, no labels, delimiter is ';', msq);

Master:
Load
Name,
Date,
Name&'_'&Date As KeyJoin,
Sum(A) as A,
Sum(B) as B,
Sum(C) as C
Resident Report_Temp
Group by Name,Date;

Drop table Master_Temp;

 

Table A:

TableA_Temp:
LOAD
FieldX As Name2,
FieldY As Date2,
FieldQ As QuantityType
If FieldQ='X',FieldU) As Quantity,

FROM [lib://DATA_Public/EX1.csv]
(txt, codepage is 28591, no labels, delimiter is ';', msq);

TableA:
Load
Name2&'_'&Date2 As KeyJoin,
Name2,
Date2,
Sum(Quantity) as Quantity
Resident TableA_Temp
Group by Name2,Date2;

Drop table TableA_Temp;

 

Table B:

TableB_Temp:
LOAD
FieldP As Name3,
FieldU As Date3,
FieldW As WeightType
If FieldW='KG',FieldJ) As Weight,

FROM [lib://DATA_Public/EX2.csv]
(txt, codepage is 28591, no labels, delimiter is ';', msq);

TableB:
Load
Name3&'_'&Date3 As KeyJoin,
Name3,
Date3,
Sum(Weight) as Weight
Resident TableB_Temp
Group by Name3,Date3;

Drop table TableB_Temp;

 

Thanks in advance!!

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Add lines with "LEFT JOIN (Master)" directly above the lines with "TableA:" and "TableB:"


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

Add lines with "LEFT JOIN (Master)" directly above the lines with "TableA:" and "TableB:"


talk is cheap, supply exceeds demand
Theo_Westseit
Contributor III
Contributor III
Author

It didnt work....

It says Table 'TableA_Temp' not found

Gysbert_Wassenaar

Then you have an error in the script you posted first to begin with.

Or perhaps you placed the LEFT JOIN line before "TableA_Temp:" instead of above "TableA:".


talk is cheap, supply exceeds demand
Theo_Westseit
Contributor III
Contributor III
Author

Your right! I placed the the LEFT JOIN line before "TableA_Temp:" instead of "TableA:".

Now it works 🙂 Thanks !!