Grouping creates independent state
Each unique combination of GROUP BY fields receives independent aggregate state. Add a window function when that state must be bounded by event time.
One result per driver and windowChronusQL
SELECT driver,
AVG(speed) AS avg_speed,
MAX(rpm) AS max_rpm,
COUNT(*) AS samples
INTO output
FROM telemetry TIMESTAMP BY ts
GROUP BY driver, TumblingWindow(Duration(second, 10))HAVING filters aggregate results
WHERE
Controls which source events contribute to state.
WHERE speed > 0HAVING
Controls which completed groups are emitted.
HAVING AVG(speed) >= 100Filter complete groupsChronusQL
SELECT driver, AVG(speed) AS avg_speed
INTO output
FROM telemetry TIMESTAMP BY ts
WHERE speed > 0
GROUP BY driver
HAVING AVG(speed) > 200Aggregate functions
| Function | Result |
|---|---|
COUNT(*) | Number of events in the group. |
AVG(field) | Arithmetic mean of numeric values. |
MIN(field) / MAX(field) | Smallest or largest value. |
STDDEV(field) | Standard deviation. |
PERCENTILE(field, p) | Percentile at numeric fraction p. |
MEDIAN(field) | Median value. |
MAD(field) | Median absolute deviation. |
REGRESSION_SLOPE(x, y) | Linear regression slope. |
REGRESSION_INTERCEPT(x, y) | Linear regression intercept. |