Selects array items by evaluating a boolean where-expression for each array element and optionally grouping it.
Syntax
select each from anArray where <where-expression> group by <group-by-expression> select first from anArray where <where-expression> group by <group-by-expression> select last from anArray where <where-expression> group by <group-by-expression> select distinct <distinct-expression> from anArray where <where-expression>
Semantics
Selects array items by evaluating a boolean where-expression for each array element and optionally grouping it. In all expressions the array element is identified by the keyword element.
The optional keyword each indicates that the select statement returns an Array containing the filtered and grouped elements.
If only the first or last array element are to be selected, use first respectively last.
If an array of unique values is to be returned use the keyword distinct.
Please note that select only selects the element references (not the content). The elements of the target array will reference to the same elements as the selected elements from the source array. Changes to an element of the target array will also change the related element in the source array.
Refer to Object References > Arrays for more general details on references and their impact, and an example.
To create an independent target array, use the copy() Operation.
Substitutables
anArray
Can be any variable or object attribute having the type Array.
<where-expression>
This is can be any expression evaluating to Boolean and containing the keyword element. The where-clause (where <where-expression>) is mandatory for all select statements except for select distinct.
<group-by-expression>
This is can be any expression containing the keyword element and returning a Base Type (except Blob).
The resulting (grouped) array is an array of type Group, where values contains the array elements that belong into that group.
The group-by clause (group by <group-by-expression>) is optional. The group-by clause must not be used in conjunction with the distinct clause.
<distinct-expression>
This is can be any expression containing the keyword element returning a Base Type (except Blob).
The distinct-clause (distinct <distinct-expression>) must not be used in conjunction with the group-by clause.
The examples below use an array of Company objects as input:
Examples
Select against a specific property from a complex array