aggregateClause
The aggregate clause accumulates a running value across query rows. An optional starting clause provides an initial accumulator value.
Examples
Sum values with starting value
from [Observation] O aggregate Total starting 0: $total + O.value
Count distinct values
from [Condition] C aggregate distinct Count starting 0: $total + 1
Build a concatenated string
from Codes C aggregate Result starting '': $total + C.code + ', '
EBNF
aggregateClause
: 'aggregate' ('all' | 'distinct')? identifier startingClause? ':' expression
;