All Group Aggregate C++ Sequence methods take an input groupBy sequence argument and produce a result sequence containing the calculated aggregate for each group. The object's sequence is split into groups based on the values in the groupBy sequence which is expected to be ordered.
Sequence<uint8> GenericSequence::groupAggCount() constReturns a sequence with the count of the number of elements in each groupSequence<T> groupAggMax(GenericSequence const& groupBy) constReturns a sequence with the maximum value for each group of elementsSequence<T> groupAggMin(GenericSequence const& groupBy) constReturns a sequence with the minimum value for each group of elementsSequence<T> groupAggFirst(GenericSequence const& groupBy) constReturns a sequence with the first element of each groupSequence<T> groupAggLast(GenericSequence const& groupBy) constReturns a sequence with the last element of each groupSequence<R> groupAggSum(GenericSequence const& groupBy) constReturns a sequence with the sum of each group of elementsSequence<double> groupAggAvg(GenericSequence const& groupBy) constReturns a sequence with the average of each group of elementsSequence<double> groupAggVar(GenericSequence const& groupBy) constReturns a sequence with the variance of each group of elementsSequence<double> groupAggVarSamp(GenericSequence const& groupBy) constReturns a sequence with the sample variance of each group of elementsSequence<double> groupAggDev(GenericSequence const& groupBy) constReturns a sequence with the Standard Deviation of each group of elementsSequence<double> groupAggDevSamp(GenericSequence const& groupBy) constReturns a sequence with the Sample Standard Deviation of each group of elementsSequence<uint4> GenericSequence::groupAggApproxDistinctCount(GenericSequence const& groupBy) constReturns a sequence with the approximate count of distinct values for each groupSequence<uint4> groupAggApproxDistinctHashValues(GenericSequence const& groupBy) constReturns a sequence with the approximate count of distinct values for each group for multiple sequences. Whereas
groupAggApproxDistinctCount()
returns the approximate distinct count for each group of a single sequence,groupAggApproxDistinctHashValues()
returns the approximate distinct count for multiple sequences.Sequence<double> groupAggWavg(GenericSequence const& weight, GenericSequence const& groupBy) constReturns the
double
result sequence with the weighted average for each groupExample
Following is an example code snippet demonstrating a group aggregate function:
{ mco_trans_h trans; mco_cursor_t quote_cursor; Quote quote; MCO_RET rc; ... rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &trans); if ( MCO_S_OK == rc ) { for (rc = mco_cursor_first(trans, "e_cursor); rc != MCO_S_CURSOR_END; rc = mco_cursor_next(trans, "e_cursor)) { Sequence<uint4> day_iterator; quote.from.cursor(trans, "e_cursor); // Calculate aggregate for each group. A group is determined by // ordered sequence elements with the same value. // Here calculate the total volume for each month of this year. quote.day_search(day_iterator, DMY(1,1,2013), MCO_SEQ_BOUNDARY_INCLUSIVE, DMY(1,1,2014), MCO_SEQ_BOUNDARY_EXCLUSIVE); print_sequence(quote, quote.volume_project(day_iterator).groupAggSum<uint8>( day_iterator / Sequence<uint4>(100) ); } mco_trans_rollback(trans); } }