|recordset||The set of records to fragment.|
|breakcriteria||Optional. A comma-delimited list of expressions or key fields in the recordset that specifies how to fragment the recordset. You may use the keyword RECORD to indicate all fields in the recordset, and/or you may use the keyword EXCEPT to list non-group fields in the structure. You may also use the keyword ROW to indicate each record in the recordset is a separate group. If omitted, the recordset is ungrouped from any previous grouping.|
|ALL||Optional. Indicates the breakcriteria is applied without regard to any previous order. If omitted, GROUP assumes the recordset is already sorted in breakcriteria order.|
|LOCAL||Optional. Specifies the operation is performed on each supercomputer node independently, without requiring interaction with all other nodes to acquire data; the operation maintains the distribution of any previous DISTRIBUTE.|
|UNORDERED||Optional. Specifies the output record order is not significant.|
|ORDERED||Specifies the significance of the output record order.|
|bool||When False, specifies the output record order is not significant. When True, specifies the default output record order.|
|STABLE||Optional. Specifies the input record order is significant.|
|UNSTABLE||Optional. Specifies the input record order is not significant.|
|PARALLEL||Optional. Try to evaluate this activity in parallel.|
|numthreads||Optional. Try to evaluate this activity using numthreads threads.|
|ALGORITHM||Optional. Override the algorithm used for this activity.|
|name||The algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options.|
|Return:||GROUP returns a record set.|
The GROUP function fragments a recordset into a set of sets. This allows aggregations and other operations (such as ITERATE, DEDUP, ROLLUP, SORT and others) to occur within defined subsets of the data--the operation executes on each subset, individually. This means that the boundary condition code written in the TRANSFORM function for those functions that use them will be different than it would be for a recordset that has simply been SORTed.
The recordset must be sorted by the same elements as the breakcriteria if the ALL option is not specified.
The recordset gets 'ungrouped' by use in a TABLE function, by the JOIN function in some circumstances (see JOIN), by UNGROUP, or by another GROUP function with the second parameter omitted.
MyRec := RECORD STRING20 Last; STRING20 First; END; SortedSet := SORT(Person,Person.last_name); //sort by last name GroupedSet := GROUP(SortedSet,last_name); //then group them SecondSort := SORT(GroupedSet,Person.first_name); //sorts by first name within each last name group // this is a "sort within group" UnGroupedSet := GROUP(GroupedSet); //ungroup the dataset MyTable := TABLE(SecondSort,MyRec); //create table of sorted names