avg method

The mean of this expression across the group.

Select position only: PostgREST has no HAVING and rejects an aggregate in order. Selecting a plain column alongside an aggregate groups by it. Needs PostgREST's db-aggregates-enabled setting, which is on for hosted Supabase. The response is keyed by the function name alone, so two aggregates of the same function in one select collide. sum, avg, min and max are null when no row matches; the type parameter describes a present value.

Implementation

PostgrestDerivedExpression<Row, double> avg() => _derive(
  _AggregateFunction.avg.suffix,
  key: _AggregateFunction.avg.name,
  fromJson: _toDouble,
);