avg
avg([value: numeric or duration]+) -> value
Computes the arithmetic mean. With a single argument in an aggregate or window() context, avg aggregates numeric values or durations (and related temporal numeric types in the numeric-or-duration class), skipping null inputs like other standard aggregates; integer and float64 inputs are averaged using floating-point division, and numeric inputs may be coerced for the division step. With more than one argument at compile time, the call is treated as a scalar mean of those expressions: the result type follows the usual widening rules, and if any argument is null the scalar form evaluates to null. Compare sum for the analogous aggregate versus scalar split.
Domain
This is an aggregate function (aggregates rows over a group in aggregate verbs).
This is a window function (calculates over a group of multiple input rows using windowing).
Categories
Examples
statsby mean_latency_ms:avg(duration_ms), group_by(service)
Computes the per-service mean duration in milliseconds with avg as a grouped aggregate over non-null samples.
make_col mid:avg(a, b, c)
Uses the scalar avg overload to average three numeric fields on each row, yielding null if any of a, b, or c is null.
Updated 19 days ago