3.3. Reading the history
last of, count, sum, min and max turn a selector into a value. The examples read the history of an account: a deposit of 100, a deposit of 50 and a withdrawal of 30.
The field of an aggregate comes after a complete selector.
3.3.1. Count and sum
count(S) is the number of events S picks; sum(T.f) adds the field f of the picked events (a field that is not a number counts as 0).
Rule text | Value | Claim |
|---|---|---|
| 150, 1 | |
| 0, null | On an empty history the sum is 0 and the last value is null. |
3.3.2. Last, min and max
The value of one picked event, or the smallest or largest. They are null when nothing is picked.
Rule text | Value | Claim |
|---|---|---|
| 50, 50, 100 | The last deposit is 50 the smallest is 50 the largest is 100. |
3.3.3. Averages
There is no avg. An average is a sum divided by a count, here of the deposits:
Rule text | Value | Claim |
|---|---|---|
| 75 |