CHOOSESETS

CHOOSESETS( recset, condition  => n [, o ][ , EXCLUSIVE | LAST | ENTH [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] ] )

recsetThe set of records to process. This may be the name of a dataset or a record set derived from some filter condition, or any expression that results in a derived record set.
conditionThe logical expression that defines which records to include in the result set.
=>The "results in" operator--valid only in CHOOSESETS, CASE, and MAP.
nThe maximum number of records to return. If zero (0), no records that meet the condition are returned.
oOptional. The maximum number of records to return that meet none of the conditions specified.
EXCLUSIVEOptional. Specifies the condition parameters are mutually exclusive.
LASTOptional. Specifies choosing the last n records that meet the condition instead of the first n. This option is implicitly EXCLUSIVE.
ENTHOptional. Specifies choosing a sample of records that meet the condition instead of the first n. This option is implicitly EXCLUSIVE.
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:CHOOSESETS returns a set of records.

The CHOOSESETS function returns a set of records from the recset. The result set is limited to n number of records that meet each condition listed. CHOOSESETS may take as many condition => n parameters as needed to exactly specify the desired set of records. This is a shorthand way of concatenating the result sets of multiple CHOOSEN function calls to the same recset with different filter conditions, but CHOOSESETS executes significantly faster. This technique is also know as a "cutback."

Example:

MyResultSet := CHOOSESETS(Person,
      per_first_name = 'RICHARD' => 100,
      per_first_name = 'GWENDOLYN' => 200, 100)
// returns a set containing 100 Richards, 200 Gwendolyns, 100 others

See Also: CHOOSEN, SAMPLE