SciDB Aggregate Operators and Functions
Some SciDB operators aggregate, or reduce, multiple expressions calaculated from values in an array into a single value, and produce an array with different dimensions.  Such operators are called aggregating operators.  Each aggregating operator and its parameters control the pattern between the input array and the output values, but make reference to one of a separate set of aggregate functions to describe the calculation desired to produce each aggregated, or reduced, output value.
The aggregating operators are:
The aggregates are:
To list all aggregate functions currently available from the libraries loaded into your SciDB, issue the following query:
AFL% list('aggregates');
Syntax
AFL Syntax
SciDB aggregate operators have the general syntax:
 aggregate_operator(array, aggregate1(expr1), [aggregate2(expr2),[ ...]], dimension1, [dimension2,[ ...]]);
where
- aggregate_operator is from the list above
- aggregate is from the list above
- expr is an expression
- dimension is a dimension along which the corresponding aggregate is computed
- each aggregate may be followed by the phrase 'as alias' where alias specifies an overriding attribute name for the result
- if expr is just an attribute name, then the result has a default name (e.g. "price_sum") which may be overridden with the phrase 'as alias'to specify the result name
- otherwise, the aggregate must have 'as alias' to specify the result name, since there is no obvious way to generate a default name.
AQL Syntaxes
SELECT aggregate1 [, aggregate2[,...]]
[INTOÂ dst-array]
FROM src-array | array-expression
[WHERE where-expression]
[REGRID AS ( PARTITION BY dimension1 dimension1-size [, dimension2 dimension2-size,[...]]) ;
SELECT aggregate1 [, aggregate2[,...]]
[INTOÂ dst-array]
FROM src-array | array-expression ]
[WHEREÂ where-expression]
[FIXED | VARIABLE WINDOW ASÂ (Â PARTITION BYÂ dimension1 dim1-low PRECEDING ANDÂ dim1-high FOLLOWING
                                              [, dimension2 dim2-low PRECEDING AND dim2-high FOLLOWING [,...]] );