Grand Aggregate C Sum, Product and Average Functions

The C mco_seq_agg_sum_TYPE(), mco_seq_agg_prd_TYPE() and mco_seq_agg_avg() functions compute the sum, product and average for the input sequence and return the result as a single element in the result sequence.

Example

Following is an example code snippet demonstrating these functions:

 
    void grand_aggregate(mco_db_h db)
    {
        mco_trans_h trans;
        mco_cursor_t quote_cursor;
        Quote quote;
        mco_seq_iterator_t close_iterator, sum_iterator, prd_iterator, avg_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);
 
                /* Initialize iterators */
                Quote_close_iterator(&quote, &close_iterator));
 
                /* Construct operator's pipeline */
                mco_seq_agg_sum_float(&sum_iterator, &close_iterator);
                mco_seq_agg_prd_float(&prd_iterator, &close_iterator);
                mco_seq_agg_avg_float(&avg_iterator, &close_iterator);
             ...
             
            }
    }