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

How to add addtional field in combined table(When use "left join" between table1 and table2?

Dear 

Directory;
LOAD [2nd_Distributor] as T2, Amount as Qty, BDCity as City, BDProvince as Province, BrandName, Category, Channel1 as Channel, CityTier, FYear as FY,
GroupName, InsCode, InsName, ListingBrandname, Month, PValue, SKUID, SKUName, SupDistributor as T1,

FROM INFY.csv (txt, utf8, embedded labels, delimiter is ',', msq);

Directory;
Left Join
LOAD Channel2 as Channel, T1Name as T1
FROM ChannelPrice.csv (txt, utf8, embedded labels, delimiter is ',', msq);

after use "left join", I created a new table. Now I need to add a new field  in this new table.

How to write the script.

thank you so much

 

 

Labels (1)
  • join

1 Solution

Accepted Solutions
Brett_Bleess
Former Employee
Former Employee

Jiang, did Arthur's final post get you a working solution?  If so, please return to the thread and use the Accept as Solution button on the posts that helped you get things working as you needed.  If you are still working upon things, leave an update with what you still need.  Marking posts gives credit to those that help out in the Community as well as lets other Community members know what actually worked  on each post.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.

View solution in original post

6 Replies
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

What is the column you want to add? A derived column?

<columnA> + <columnB> as <columnC>

smallbee001
Contributor
Contributor
Author

Directory;
LOAD [2nd_Distributor] as T2, Amount as Qty, BDCity as City, BDProvince as Province, BrandName, Category, Channel1 as Channel, CityTier, FYear as FY,
GroupName, InsCode, InsName, ListingBrandname, Month, PValue, SKUID, SKUName, SupDistributor as T1,
Tier1ERPCode, Value, WWBID, Year, YM
FROM INFY.csv (txt, utf8, embedded labels, delimiter is ',', msq);


Directory;
Left Join
LOAD Channel2 as Channel, T1Name as T1, T2Name as T2, InsCode, InsName, SubBrand, T1_In_Price, T1_Out_Price, T2_Out_Price,
T2_In_Price
FROM ChannelPrice.csv (txt, utf8, embedded labels, delimiter is ',', msq);

[INFY]:
Load (PVaule < 1000) as Flag
Resident [INFY]

add this field use IF function, 

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

tempINFY:

load *,if(PVaule < 1000,1,0) as Flag

resident INFY;

drop table INFY;

rename table tempINFY to INFY;

smallbee001
Contributor
Contributor
Author

字段未找到 - <PVaule>
tempINFY:

load *,if(PVaule < 1000,1,0) as Flag

resident INFY

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

tempINFY:

load *,if(PValue < 1000,1,0) as Flag

resident INFY;

drop table INFY;

rename table tempINFY to INFY;

Brett_Bleess
Former Employee
Former Employee

Jiang, did Arthur's final post get you a working solution?  If so, please return to the thread and use the Accept as Solution button on the posts that helped you get things working as you needed.  If you are still working upon things, leave an update with what you still need.  Marking posts gives credit to those that help out in the Community as well as lets other Community members know what actually worked  on each post.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.