Aggregate and analytic functions

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, ...

Get Stream Analytics with Microsoft Azure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.