Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
Can you please suggest what would be optimized code for code given below.
if(FuelType='Diesel' or FuelType='DIESEL','Diesel',If(FuelType='LPG','LPG',If(FuelType='CNG','CNG')))as FuelType
If fuel type is Diesel or DIESEL then i need to display DIESEL or if fuel type is CNG then CNG and if LPG then LPG.
Thanks,
Deepak
You can try with
if(Match(FuelType='Diesel','DIESEL'),'DIESEL',
If(Match(FuelType='LPG'),'LPG',
If(Match(FuelType='CNG'),'CNG'))) as FuelType
Load *,
upper(trim(FuelType) ) as NewFuelType
from path;
Another way is
Load
Trim(if(Match(FuelType='Diesel','DIESEL'),'DIESEL',
If(Match(FuelType='LPG'),'LPG',
If(Match(FuelType='CNG'),'CNG'))) ) as FuelType
From Location;
Hi Anand,
It is giving me syntax error.
Hi Deepak,
Try this
if(Upper(FuelType)='DIESEL','DIESEL',if(Upper(FuelType)='LPG','LPG',if(Upper(FuelType)='CNG','CNG')))
=if(Match(FuelType,'Diesel' ,'DIESEL','LPG','CNG'),Upper(FuelType))