Aggregate functions perform calculations on a group of events and return a single event or value. Aggregate functions are deterministic, so given the same input, they will always return the same result. They can only be used in a projection (that is, a SELECT clause) or an aggregate constraint (that is, a HAVING clause). For example, AVG returns the average of values in a group.
The following example, based on an incoming stream of data from connected vehicles, shows average vehicle speed in each city, calculated per minute:
select System.Timestamp as WindowEndTimestamp, ehinput.city, AVG(ehinput.speed) as average_speedfrom ehinput timestamp by ehinput.timestampgroup by ehinput.city, TumblingWindow(minute, ...