Grand Aggregate C Sequence Functions

All Grand Aggregate C functions take a single input sequence and produce a result sequence. The result of all Grand Aggregate functions is returned in the first element of the result sequence as a double value except for mco_seq_agg_count() which returns a uint8 value and the two functions mco_seq_agg_approxdc() and mco_seq_agg_approxdc_hash() which return uint4 values.

The function signatures are of the following form:

    MCO_RET mco_seq_agg_operation(
        mco_seq_iterator_h result,
        mco_seq_iterator_h input
    );

or

    MCO_RET mco_seq_agg_operation_TYPE(
        mco_seq_iterator_h result,
        mco_seq_iterator_h input
    );

where TYPE is one of the types listed in the Analytics Functions page and operation is one of the following. Please use the links below to view descriptions and examples of the individual functions:

mco_seq_agg_count()
Count of all elements.
mco_seq_agg_count_not_null()
Count of non-NULL elements, returned as one uint8 result; an empty or all-NULL input returns zero.
mco_seq_agg_max_TYPE()
Maximum element value.
mco_seq_agg_min_TYPE()
Minimum element value.
mco_seq_agg_min_max_TYPE()
Both maximum and minimum element value.
mco_seq_agg_sum_TYPE()
Sum of all elements.
mco_seq_agg_prd_TYPE()
Product of all elements.
mco_seq_agg_avg_TYPE()
Average of all elements.
mco_seq_agg_var_TYPE()
Variance of elements.
mco_seq_agg_var_samp_TYPE()
Sample Variance of elements.
mco_seq_agg_dev_TYPE()
Standard Deviation of elements.
mco_seq_agg_dev_samp_TYPE()
Sample Standard Deviation of elements.
mco_seq_agg_approxdc()
Approximate count of distinct values.
mco_seq_agg_approxdc_hash()
Approximate count of distinct values for multiple sequences.

Example

Following is an example code snippet demonstrating a grand aggregate function:

    {
        mco_trans_h trans;
        mco_cursor_h quote_cursor;
        Quote quote;
        mco_seq_iterator_h close_iterator, max_iterator;
        MCO_RET rc;
        ...
        for (rc = mco_cursor_first(trans, &quote_cursor);
            rc != MCO_S_CURSOR_END;
            rc = mco_cursor_next(trans, &quote_cursor))
        {
            Quote_from_cursor(trans, &quote_cursor, &quote);
            Quote_close_iterator(&quote, &close_iterator);
            ...
            rc = mco_seq_agg_max_float(&max_iterator, &close_iterator);
            ...
        }
        ...
    }