Aggregation operators
You can use aggregation operators over a collection of objects. Aggregation operators calculate the average, total, minimum, or maximum value of the numeric attributes in a collection of objects, or the number of objects in a collection.
Aggregation operators compute a value from a collection of values.
You cannot use aggregation operators in the action part of the rule.
Operator | Description | Example |
---|---|---|
the average <attribute> of <collection> |
Calculates the average value of an attribute in the collection of objects. |
|
the minimum <attribute> of <collection> |
Returns the minimum value of an attribute in the collection of objects. |
|
the maximum <attribute> of <collection> |
Returns the maximum value of an attribute in the collection of objects. |
|
the total <attribute> of <collection> |
Calculates the total value of an attribute in the collection of objects. |
|
the number of <collection> |
Returns the number of objects in a collection. When this operator is applied to a collection that is defined by the all construct, the article is removed to improve readability. |
|
Example
if
the total amount of all purchase events,
where the time of each purchase is during the last period of 1 week, is more than 1000
then
print "too much spending in 7 consecutive days.";