Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Team,
Can someone help me in this scenario.
I have a table:
TABLE1:
Load * Inline [
DESC, VALUE
A,10
B,20
C,30
D, 40
];
Load *,
Sum(if (DESC = 'D'),Value) / Sum(if (DESC = 'B'),Value) as DIVIDE
Resident TABLE1
GROUP BY 1,2;
I am expecting DIVIDE field should be 2 but its returning 0. What wrong I am doing here?
Division should be done only in backend script.
Cam someone help me please.
Thanks
wth... you need to make different fields of your Desc's in order to be able to use them...
TABLE1:
Load * Inline [
DESC, VALUE
A,10
B,20
C,30
D, 40
];
TEMPcalculations:
load
VALUE as D_Value
resident TABLE1
where DESC= 'D';
left join(TEMPcalculations)
load
VALUE as B_Value
resident TABLE1
where DESC= 'B';
Calculations:
load
B_Value,
D_Value,
D_Value/B_Value as DIVIDE
resident TEMPcalculations;
drop table TEMPcalculations;
if (DESC = 'D',sum(Value)) / if (DESC = 'B',sum(Value))