avg — aggregate function to determine the mean average of a field or column.




This function computes a value for each record returned by the query predicate and returns the mean average of the specified values.

The argument expr must include the name of a column in a LiveView table, where that column's data type is int, long, double, or timestamp. The returned value is of the same data type.


This example shows how to use dynamic aggregation to find the average for values in a column. In the Hello LiveView sample, create a query that finds the average of the lastSoldPrice field from the ItemsSales table, grouping by Item. Follow these steps:

  1. In LiveView Desktop connected to a server running the Hello LiveView sample, select the ItemsSales table from the Tables pane of the LiveView Tables view.

  2. In the Select field, enter:

    Item, avg(lastSoldPrice) AS avgPrice
  3. In the Query field, enter the following:

    group by Item
  4. Click Open Query.

The query results open in a grid view. LiveView Server recalculates the average whenever the rows returned by the query predicate change.


This LiveView aggregate function is based on the avg aggregate function in the StreamBase expression language.