- TIBCO BusinessEvents®
- CEP Query
- Query
- Datagrid
- Aggregate

# Query.Datagrid.Aggregate.groupAvgList()

## Signature

`Object groupAvgList(String resultSetName, String entityUri, String fieldName, String filter, String... groupByFieldNames)`

## Domain

QUERY, ACTION

## Description

Find the average of the entities from the field specified by field name, of the specified URI, which satisfies the condition in the filter for each group.

## Parameters

Name | Type | Description
--- | --- | ---
`resultSetName` | `String` | The resultset name
`entityUri` | `String` | The entity uri.
`fieldName` | `String` | Name of the field used for computation.
`filter` | `String` | Condition to be satisfied by the entities in the result.
`groupByFieldNames` | `String...` | Names of the fields in groupBy clause.

## Returns

Type | Description
--- | ---
`Object` | Return a List of rows. Each row may be a single Object column or an Object[] of columns.

## Cautions

none

## Example

`String resultSetName = "groupAvgListRS" ;
Object resultSet = Query.Datagrid.Aggregate.groupAvgList(resultSetName, "/Concepts/Employee","exp","age < 4", "age", "dept");
//Iterate over the result set
while(Query.Util.sizeOfList(resultList) > 0){
Object[] s = Query.Util.removeFromList(resultList, 0);
/* s[0]-- age, s[1]-- exp, s[2]-- average exp of the employee entities
satisfying the filter condition for this age and exp */
System.debugOut(resultSetName + " :: " + s[0] + " : "+ s[1] + " : "+ s[2]);
}```