Grouped Aggregate Query
aggregate_groupedCompute COUNT, AVG, MIN, MAX, or SUM grouped by a field on a ServiceNow table. Returns per-group statistics for data breakdowns.
Instructions
Run aggregate functions (COUNT, AVG, MIN, MAX, SUM) grouped by a field on any ServiceNow table. Returns per-group statistics — ideal for breakdowns and dashboards.
Examples: count of incidents grouped by priority, average resolution time grouped by category, sum of story points grouped by assignee.
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"). | |
| group_by | Yes | The field name(s) to group by (e.g., ["priority"], ["state", "category"]). Pass a single-element array for simple grouping. | |
| query | No | An encoded query string to filter records before aggregation. | |
| count | No | When true, include a COUNT per group. | |
| avg_fields | No | Field names to compute AVG on per group. | |
| min_fields | No | Field names to compute MIN on per group. | |
| max_fields | No | Field names to compute MAX on per group. | |
| sum_fields | No | Field names to compute SUM on per group. | |
| having | No | A HAVING clause to filter groups after aggregation (e.g., "COUNT>10" to only return groups with more than 10 records). | |
| display_value | No | Display value handling: "true" returns display values, "false" returns internal values, "all" returns both. |