Vertica Analytics Platform Version 9.2.x Documentation

AVG [Aggregate]

Computes the average (arithmetic mean) of an expression over a group of rows. AVG always returns a DOUBLE PRECISION value.

The AVG aggregate function differs from the AVG analytic function, which computes the average of an expression over a group of rows within a window.

Behavior Type

Immutable

Syntax

AVG ( [ ALL | DISTINCT ] expression )

Parameters

ALL

Invokes the aggregate function for all rows in the group (default).

DISTINCT

Invokes the aggregate function for all distinct non-null values of the expression found in the group.

expression

The value whose average is calculated over a set of rows, any expression that can have a DOUBLE PRECISION result.

Overflow Handling

By default, Vertica allows silent numeric overflow when you call this function on numeric data types. For more information on this behavior and how to change it, see Numeric Data Type Overflow with SUM, SUM_FLOAT, and AVG.

Examples

The following query returns the average income from the customer table:

=> SELECT AVG(annual_income) FROM customer_dimension;
     AVG      
--------------
 2104270.6485
(1 row)