Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
Hi,
i have 2 fields in one table, need to derive one more field based on the 2 existing fields, please suggest me how to achieve this.
 
					
				
		
 simenkg
		
			simenkg
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Field1 + Field2 as Field3, //Returns the sum of the two fields
Field1 & Field2 as Field4, //Returns the concatenated string of the two fields.
You should get the picture.
 
					
				
		
Hi Savi,
a bit more detail on what you are trying to get as your end result would be good.
If you are just trying to combine the two fields, you can use '&' and alias as a new field.
eg. FieldA & FieldB As Field C
Or with a separator FieldA & '|' & FieldB As FieldC
hope that help
Joe
 its_anandrjs
		
			its_anandrjs
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi,
If this fields are string or number you can concatenate this fields or if conditionally you can to create it you can do this in the load script
Load
Field1,
Field2,
Field1&'-'&Field2 as Newfield
From Location;
Or
Load
Field1,
Field2,
If(Field1=2 and Field2 <= 5,Field1,Field2) as Newfield
From Location;
It depends on the conditions. Provide if you have any sample date.
Regards
Anand
 Kushal_Chawda
		
			Kushal_Chawda
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		what exactly you want to calculate?
 
					
				
		

 anbu1984
		
			anbu1984
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		For field2 <> b, how do you derive output?
 its_anandrjs
		
			its_anandrjs
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Write like
Load
Field1,
Field2,
if( Field2 = 'b','y') as OP
From Location;
With your snap shot not understood provide any sample for this in any inline table or excel file for exlanation
Regards
Anand
 
					
				
		
if field2 has 'b' then for all field1 records having 'x' o/p should be 'Y'
if field2 doesn't have 'b' then for all field1 records having 'x' o/p should be 'N'
 its_anandrjs
		
			its_anandrjs
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Why not you directly check the Field1 for this.
or you can try
LOAD Field1,Field2,if(Field2='b','Y','N') as Flag,RowNo() as RID;
LOAD * Inline
[
Field1,Field2
x,a
x,a
x,a
x,b
x,b
y,a
y,a
y,a
y,b
y,b
]
Regards
Anand
