REGROUP

REGROUP(recset,...,recset [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

recsetA grouped set of records. Each recset must be of exactly the same type and must contain the same number of groups.
UNORDEREDOptional. Specifies the output record order is not significant.
ORDEREDSpecifies the significance of the output record order.
boolWhen False, specifies the output record order is not significant. When True, specifies the default output record order.
STABLEOptional. Specifies the input record order is significant.
UNSTABLEOptional. Specifies the input record order is not significant.
PARALLELOptional. Try to evaluate this activity in parallel.
numthreadsOptional. Try to evaluate this activity using numthreads threads.
ALGORITHMOptional. Override the algorithm used for this activity.
nameThe algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options.
Return:REGROUP returns a record set.

The REGROUP function combines the grouped recsets into a single grouped record set. This is accomplished by combining each group in the first recset with the groups in the same ordinal position within each subsequent recset.

Example:

inrec := {UNSIGNED6 did};

outrec := RECORD(inrec)
  STRING20 name;
  UNSIGNED score;
END;

ds := DATASET([1,2,3,4,5,6], inrec);
dsg := GROUP(ds, ROW);

i1 := DATASET([{1, 'Kevin', 10},
               {2, 'Richard', 5},
               {5, 'Nigel', 2},
               {0, '', 0}], outrec);
i2 := DATASET([{1, 'Kevin Halligan', 12},
               {2, 'Ricardo Chapman', 15},
               {3, 'Jake Smith', 20},
               {5, 'David Hicks', 100},
               {0, '', 0}], outrec);
i3 := DATASET([{1, 'Halligan', 8},
               {2, 'Ricardo', 8},
               {6, 'Pete', 4},
               {6, 'Peter', 8},
               {6, 'Petie', 1},
               {0, '', 0}], outrec);

j1 := JOIN(dsg, i1, LEFT.did = RIGHT.did, LEFT OUTER, MANY LOOKUP);
j2 := JOIN(dsg, i2, LEFT.did = RIGHT.did, LEFT OUTER, MANY LOOKUP);
j3 := JOIN(dsg, i3, LEFT.did = RIGHT.did, LEFT OUTER, MANY LOOKUP);
  
combined := REGROUP(j1, j2, j3);
OUTPUT(j1);
OUTPUT(j2);
OUTPUT(j3);
OUTPUT(combined);

See Also: GROUP, COMBINE