> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pinkfish.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# servicenow-aggregate

> ServiceNow Aggregate - count, sum, avg, min, max, and groupBy on any table

**Server path:** `/servicenow-aggregate` | **Type:** Application | **PCID required:** Yes

## Tools

| Tool                                                                          | Description                             |
| ----------------------------------------------------------------------------- | --------------------------------------- |
| [`servicenow_aggregate_get_statistics`](#servicenow_aggregate_get_statistics) | Compute aggregate statistics on a table |

***

## servicenow\_aggregate\_get\_statistics

Compute aggregate statistics on a table

**Parameters:**

| Parameter               | Type    | Required | Default | Description                                                                     |
| ----------------------- | ------- | -------- | ------- | ------------------------------------------------------------------------------- |
| `tableName`             | string  | Yes      | —       | Name of the table to aggregate (e.g., incident, change\_request, task)          |
| `sysparm_query`         | string  | No       | —       | Encoded query to filter records before aggregating (e.g., 'state=1^priority=2') |
| `sysparm_count`         | boolean | No       | —       | Set to true to return the total record count                                    |
| `sysparm_avg_fields`    | string  | No       | —       | Comma-separated fields to compute the average for                               |
| `sysparm_sum_fields`    | string  | No       | —       | Comma-separated fields to compute the sum for                                   |
| `sysparm_min_fields`    | string  | No       | —       | Comma-separated fields to find the minimum value for                            |
| `sysparm_max_fields`    | string  | No       | —       | Comma-separated fields to find the maximum value for                            |
| `sysparm_group_by`      | string  | No       | —       | Comma-separated fields to group results by (e.g., 'state,priority')             |
| `sysparm_having`        | string  | No       | —       | Filter on aggregated results (e.g., 'COUNT(sys\_id)>5')                         |
| `sysparm_order_by`      | string  | No       | —       | Order results by field or aggregate (e.g., 'state' or 'COUNT(sys\_id)')         |
| `sysparm_display_value` | string  | No       | —       | Return display values (true), actual values (false), or both (all)              |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID for the authenticated connection"
      },
      "tableName": {
        "type": "string",
        "description": "Name of the table to aggregate (e.g., incident, change_request, task)"
      },
      "sysparm_query": {
        "type": "string",
        "description": "Encoded query to filter records before aggregating (e.g., 'state=1^priority=2')"
      },
      "sysparm_count": {
        "type": "boolean",
        "description": "Set to true to return the total record count"
      },
      "sysparm_avg_fields": {
        "type": "string",
        "description": "Comma-separated fields to compute the average for"
      },
      "sysparm_sum_fields": {
        "type": "string",
        "description": "Comma-separated fields to compute the sum for"
      },
      "sysparm_min_fields": {
        "type": "string",
        "description": "Comma-separated fields to find the minimum value for"
      },
      "sysparm_max_fields": {
        "type": "string",
        "description": "Comma-separated fields to find the maximum value for"
      },
      "sysparm_group_by": {
        "type": "string",
        "description": "Comma-separated fields to group results by (e.g., 'state,priority')"
      },
      "sysparm_having": {
        "type": "string",
        "description": "Filter on aggregated results (e.g., 'COUNT(sys_id)>5')"
      },
      "sysparm_order_by": {
        "type": "string",
        "description": "Order results by field or aggregate (e.g., 'state' or 'COUNT(sys_id)')"
      },
      "sysparm_display_value": {
        "type": "string",
        "description": "Return display values (true), actual values (false), or both (all)",
        "enum": [
          "true",
          "false",
          "all"
        ]
      }
    },
    "required": [
      "PCID",
      "tableName"
    ]
  }
  ```
</Expandable>
