Aggregate Records
aggregate_recordsAggregate ServiceNow table records with COUNT, AVG, MIN, MAX, SUM, and optional GROUP BY filters, returning grouped stats for reporting and analysis.
Instructions
Aggregate records using COUNT, AVG, MIN, MAX, SUM with optional GROUP BY via the Stats API.
If the Stats API is refused (401) while list_records works, count with list_records instead: the same query, fields="sys_id", limit=1000, paging with offset.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Include record count in results | |
| query | No | Encoded query string to filter records before aggregation | |
| having | No | Post-aggregation filter, aggregate^field^operator^value (e.g., 'count^name^>^1') | |
| group_by | No | Comma-separated fields to group results by (e.g., 'priority,state') | |
| avg_fields | No | Comma-separated fields to average (e.g., 'reassignment_count,reopen_count') | |
| max_fields | No | Comma-separated fields to find maximum values | |
| min_fields | No | Comma-separated fields to find minimum values | |
| sum_fields | No | Comma-separated fields to sum | |
| table_name | Yes | The ServiceNow table name (e.g., 'sys_user_group', 'cmdb_ci', 'incident') | |
| display_value | No | 'false' (default) returns stored group_by values; 'true' returns labels in place of sys_ids and choice values; 'all' returns both. query= still filters on stored values, not labels | false |