max
The max aggregate returns the maximum value of a set of scalar values from an array attribute.
Synopsis
aggregate(array, max(attribute) [,dimension_1, dimension_2,...])
Summary
The max aggregate takes a set of scalar values from an array attribute and returns the maximum value. You can optionally specify one or more dimensions by which to group.
The maximum value of an empty set is NULL.
The maximum of a set that contains only NULL values is also NULL.
If the set contains NULL and NOT NULL values, the max aggregate considers only NOT NULL values.
Example
To find the maximum value of each row of a 2-dimensional array, do the following:
Create a 1-attribute, 2x3-dimensional array called m2x3:
AFL% store(build(<val:double>[r=1:2; c=1:3], '[ [3,2,1] [1,4,3] ]',true),m2x3);
The output is:{1,1} 3 {1,2} 2 {1,3} 1 {2,1} 1 {2,2} 4 {2,3} 3Select the maximum value of each row of m2x3:
AFL% aggregate(m2x3,max(val),r);
The output is:{r} val_max {1} 3 {2} 4Select the maximum value of each column of m2x3:
AFL% aggregate(m2x3,max(val),c);The output is:
{c} val_max {1} 3 {2} 4 {3} 3Remove the example array:
AFL% remove(m2x3);