prod
The prod aggregate calculates the cumulative product of a group of values.
Synopsis
AFL% aggregate(array,prod(attribute)[,dimension_1,dimension_2,...])
AQL% SELECT prod(attribute) FROM array [GROUP BY dimension_1,dimension_2,...]
Summary
The prod aggregate calculates the cumulative product of a group of values. The product of an empty set is 0. The product of a set that contains only NULL values is also 1. If the set contains NULL and NOT NULL values, the result is the product of all the NOT NULL values.
Example
To find the product of every column of a 3×3 array, do the following:
Create and array, m3x3, and store values of 1–9 into it:
AFL% store(build(<val:double>[row=0:2; col=0:2],row*3+col+1),m3x3);
The output is:{row,col} val {0,0} 1 {0,1} 2 {0,2} 3 {1,0} 4 {1,1} 5 {1,2} 6 {2,0} 7 {2,1} 8 {2,2} 9
Find the product of each column in m3x3:
AFL% aggregate(m3x3,prod(val),col)Â
The output is:{col} val_prod {0} 28 {1} 80 {2} 162
Find the product of all the cells of m3x3:
AFL% aggregate(m3x3,prod(val))Â
The output is:{i} val_prod {0} 362880
The array can be removed now.
remove(m3x3);
The output is:Query was executed successfully