Aggregate Query
aggregate_queryRun aggregate functions (COUNT, AVG, MIN, MAX, SUM) on any ServiceNow table to compute statistics without retrieving individual records.
Instructions
Run aggregate functions (COUNT, AVG, MIN, MAX, SUM) on any ServiceNow table using the Stats API. Returns computed statistics without returning individual records.
Examples: average resolution time for incidents, max priority across open changes, sum of story points in a sprint, count of active users.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instance | No | The ServiceNow instance auth alias (e.g., "myinstance", "prod"). If not provided, falls back to the SN_AUTH_ALIAS environment variable. | |
| table | Yes | The ServiceNow table name (e.g., "incident", "change_request"). | |
| query | No | An encoded query string to filter records before aggregation. If omitted, aggregates over all records. | |
| count | No | When true, include a COUNT in the results. | |
| avg_fields | No | Field names to compute AVG on (e.g., ["reassignment_count", "reopen_count"]). | |
| min_fields | No | Field names to compute MIN on. | |
| max_fields | No | Field names to compute MAX on. | |
| sum_fields | No | Field names to compute SUM on. | |
| display_value | No | Display value handling: "true" returns display values, "false" returns internal values, "all" returns both. If omitted, returns internal values. |