---
schema_version: "1"
id: 97b6d3b16acc8619518d1f069f36af02b29bfa09d8f8e789808bd8260b846ba3
title: Order Aggregate Results
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/graphql-api/graphql/guides/aggregate/aggregate-orderby.md
canonical_url: https://developer.salesforce.com/docs/platform/graphql/guide/aggregate-orderby.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 011dd1ef02f496971db532818926f56400784b71ca3d3663a1587528505224bf
products:
  - GraphQL API
---
# Order Aggregate Results

| AVAILABLE API VERSION |
| --------------------- |
| API v59.0 and later   |

Use the `orderBy` argument to sort the aggregate results alphabetically in either ascending or descending order. You can also specify if null values appear first in the result set.

When querying a [`RecordAggregate`](https://developer.salesforce.com/docs/platform/graphql/guide/aggregate.md#recordaggregate-type), you can pass in an aggregate function and a `orderBy` argument. If you don't need aggregation, use the [`RecordQuery` type](https://developer.salesforce.com/docs/platform/graphql/query/query-record-objects.md) instead.

The `orderBy` argument behaves like the [SOQL `ORDER BY` clause](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_orderby.htm).

**note:** To use the `orderBy` argument, your field must be grouped or aggregated.

All sObjects in the schema have a corresponding order type. The order type combines the API name with the `_OrderBy`. For example, under the `RecordQueryAggregate` fields, `Account` has a corresponding `Account_OrderBy` type. See [Aggregate Schema](https://developer.salesforce.com/docs/platform/graphql/guide/aggregate-schema.md).

The following field types support ordering. Each field type corresponds to an `AggregateOrderByClause` type. See [Order By Schema](https://developer.salesforce.com/docs/platform/graphql/guide/aggregate-orderby-schema.md).

- Int
- String
- Boolean
- Id
- DateTime
- Time
- Date
- TextArea
- LongTextArea
- PhoneNumber
- Email
- Url
- Currency
- Geolocation
- Longitude
- Latitude
- Picklist
- Long
- Double
- Percent
- Base64
