Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Nittin16
Partner - Contributor
Partner - Contributor

Divide in backend script not working returning zero - PLEASE URGENT HELP

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

Labels (3)
2 Replies
mikaelsc
Specialist
Specialist

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;

anat
Master
Master

if (DESC = 'D',sum(Value)) / if (DESC = 'B',sum(Value))