Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
Can any one give the solution.
These are actual table fields.
A B C
Health 3 -
Health - 15
but I require B/C in scripting.
Thanks
krish
You require B/C in scripting? You want to be able to divide them?
May be like this:
LOAD A,
Sum(B)/Sum(C) as [B/C]
From ...
Group By A;
something like this
LOAD A,
if(len(trim(B))>0,B,C) as B_C
from table ;
could you please explain what is the output your excepting ??
Hi,
Just confirm should the final data look like
Health 3 15
Probably something like
DataTemp:
Load
A,
B
From ...
Where LEN(B) > 0;
Join
Load
A,
C
From ...
Where LEN(C) > 0;
NoConcatenate
Data:
LOAD
A,
B,
C,
B / C AS D
RESIDENT DataTemp;
Drop table DataTemp;
Mark
Hi Sunny,
Did not get that scripting. It is returns the invalid expression.
I require Division of B/C.
Thanks
krish
Did you use Group By Statement?
Hi Avinash,
I require only Division of B/C.
Thanks
Giri
Yes
Hi,
Try this code:
MyTable:
LOAD * INLINE [
A, B, C
Health,3,
Health,,15
];
Final:
LOAD
A,
Sum(If(IsNull(B),0,B)) as SumB,
Sum(If(IsNull(C),0,C)) as SumC,
IF(Sum(If(IsNull(C),0,C)) = 0,0,
Sum(If(IsNull(B),0,B))/Sum(If(IsNull(C),0,C))) as [B/C]
RESIDENT MyTable
Group By A;
Use IsNull to set 0 when B or C is null, if Sum(C) is null it will return 0 on B/C field.
Regards!
Hi Sunny,
I require B,C fields also. It is possible to without B,C fields.