Aggregate Query
aggregate_queryRun aggregate functions (COUNT, AVG, MIN, MAX, SUM) on ServiceNow tables using the Stats API. Returns computed statistics without individual records, for insights like average resolution time or total story points.
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 |
|---|---|---|---|
| count | No | When true, include a COUNT in the results. | |
| query | No | An encoded query string to filter records before aggregation. If omitted, aggregates over all records. | |
| table | Yes | The ServiceNow table name (e.g., "incident", "change_request"). | |
| instance | No | The ServiceNow instance auth alias (e.g., "myinstance", "prod"). If not provided, falls back to the SN_AUTH_ALIAS environment variable. | |
| avg_fields | No | Field names to compute AVG on (e.g., ["reassignment_count", "reopen_count"]). | |
| max_fields | No | Field names to compute MAX on. | |
| min_fields | No | Field names to compute MIN 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. |