min

The min aggregate returns returns the minimum value of a set of scalar values from an array attribute.

Synopsis

aggregate(array,min(attribute)[,dimension_1,dimension_2,...])

Summary

The min aggregate takes a set of scalar values from an array attribute and returns the minimum value. You can optionally specify one or more dimensions by which to group.

The minimum value of an empty set is NULL. The minimum of a set that contains only NULL values is also NULL. If the set contains NULL and NOT NULL values, the min aggregate considers only NOT NULL values.

Example

To find the minimum value of each row of a 2-dimensional array, do the following:

  1. Create a 1-attribute, 2-dimensional array called m3x3:

    AFL% CREATE ARRAY m3x3 <val:double>[i=0:2; j=0:2];
  2. Store random values in m3x3:

    AFL% store(build(m3x3, (i+j)*109%10), m3x3);


    The output is:

    {i,j} val
    {0,0} 0
    {0,1} 9
    {0,2} 8
    {1,0} 9
    {1,1} 8
    {1,2} 7
    {2,0} 8
    {2,1} 7
    {2,2} 6
  3. Select the minimum value of each row of m3x3:

    AFL% aggregate(m3x3,min(val),i); 


    The output is:

    {i} val_min
    {0} 0
    {1} 7
    {2} 6