Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Want to make a querry for XYZ column for below condition.
we have three fields vat1, vat2, vat3.
xyz is vat1 if only numeric value for vat1 exists
xyz is vat3 if vat3 exists
xyz is vat2 if vat2 exists
Something like this:
load
vat1
, vat2
, vat3
, if(isnum(vat1), vat1, if(len(trim(vat3))>0,vat3,if(len(trim(vat2))>0,vat2))) as XYZ
from ...mysource...;
TAB:
SELECT * From MyTable;
TABFINAL:
Load
*,
if(isnum(vat1)),num(vat1), if(not isnull(vat2), vat2, vat3)) as xyz
resident TAB;
drop table TAB;
you may have to elaborate a bit more. in your example, what if more than one condition is true? what would the result be? if the conditions are sequential - check for 2 if 1 is not satisfied, etc. then following should help:
in your load statement, you can add the following:
load
vat1,
vat2,
vat3,
if(isnum(vat1),vat1,if(isnull(vat2),if(isnull(vat3),0,vat3),vat2)) as xyz
from
...;
replace 0 in the above expression with the answer to what if none of the conditions are satisfied.