---
title: aggregate
description: Query a table using an aggregate function including SUM, COUNT, MIN, MAX, LAST, and AVG.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/web-services/r\_Aggregate.html
release: australia
product: Web Services
classification: web-services
topic_type: reference
last_updated: "2026-03-12"
reading_time_minutes: 1
breadcrumb: [Data Retrieval, API functions, Direct services, SOAP web service, Inbound, Web services, API implementation, API implementation and reference]
---
# aggregate
Query a table using an aggregate function including SUM, COUNT, MIN, MAX, LAST, and AVG.
**Note:** Functionality described here requires the Aggregate Web Service plugin.
## Input fields
Any element of the target table. In addition, one or more of the aggregate functions \(SUM, COUNT, MIN, MAX, LAST, and AVG\).
A GROUP BY and a HAVING clause may also be added.
## Output fields
An aggregateResponse element encapsulating all field values for the record retrieved.
## Sample SOAP messages
Sample SOAP request using COUNT aggregate function.
```
number
true
```
The resulting response of a COUNT aggregate function call looks like this:
```
2.7200
```
Sample SOAP request using AVG aggregate function with a GROUP BY clause.
```
category
true
severity
```
The resulting response of a AVG aggregate function call with a GROUP BY clause looks like this:
```
1.0000
database
3.0000
hardware
3.0000
inquiry
2.0000
network
2.6923
software
```
Sample SOAP request using an encoded query to filter the aggregate:
```
number
true
<__encoded_query>number=INC0000001^ORnumber=INC0000002
```
Sample aggregate request using HAVING to narrow the results.
HAVING takes four fields. Each field is delimited by "^": the aggregate type, the field of the aggregate, the operation type, and the value to compare.
More than one HAVING can be added to the request, so you can use HAVING expressions, but there is no support for OR.
```
sys_id
internal_type
COUNT^*^>^10
COUNT^*^<^20
sys_id
true
```
**Parent Topic:**[Data Retrieval API](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/web-services/r_DataRetrievalAPI.md)