Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
Can any one explain the precedence in which the expressions in funtions are beign evaluated
for example
Avg(Aggr(Sum(UnitSales*UnitPrice), Customer))
ProductData:
LOAD * inline [
Customer|Product|UnitSales|UnitPrice
Astrida|AA|4|16
Astrida|AA|10|15
Astrida|BB|9|9
Betacab|BB|5|10
Betacab|CC|2|20
Betacab|DD|25|25
Canutility|AA|8|15
Canutility|CC||19
] (delimiter is '|');
Thanks
vijay kumar
this is the avrage sales amount=Sum(UnitSales*UnitPrice) grouped by customer.
this is the avrage sales amount=Sum(UnitSales*UnitPrice) grouped by customer.
Aggr will build a internal temporary table with 2 columns Sum(UnitSales*UnitPrice) and customer.
Avg will be evaluated on that table
1st - By - Aggr(Sum(UnitSales*UnitPrice),Customer) expression
For each Customer, it calculates - Sum(UnitSales*UnitPrice) -
So - Customer wise - Astrida - 4*16 + 10*15 + 9*9 = 295,
- Betacab - 5*10 + 2*20 + 25*25 = 715
- Canutility - 8*15 = 120
Now the above Aggr() function is having values, as - 295,715,120.
2nd - The above values are passed as Input to Avg function -
Then it'll be like - Avg(295,715,120) - It calculates Avg of those 3 values & output will be: 376.66.
So this is the process happens with the above expression.