The online Trailblazer Community becomes read-only Oct 30, 2026. Read More
| AVAILABLE API VERSION |
|---|
| API v59.0 and later |
All sObjects in the schema have a corresponding RecordOrderBy type. The RecordOrderBy type combines the object API name with the _OrderBy suffix. For example:
1type Account {
2 groupBy: Account_GroupBy
3 orderBy: Account_OrderBy
4}The RecordOrderBy type is introduced by the RecordQueryAggregate type.
RecordOrderBy creates one input type per sObject type. For example, Account has a corresponding Account_OrderBy type that you can use with the orderBy argument.
The Account_OrderBy type contains fields of OrderByClause type. Some fields are shown here for brevity. We recommend that you use the Altair GraphQL client for a complete view of the schema.
1input Account_OrderBy {
2 AccountNumber: AggregateOrderByStringClause
3 AnnualRevenue AggregateOrderByNumberClause
4 BillingCity: AggregateOrderByStringClause
5 BillingCountry: AggregateOrderByStringClause
6 CreatedBy: User_OrderBy
7 CreatedById: NoFunctionAggregateOrderByClause
8 Id: AggregateOrderByStringClause
9 Industry: AggregateOrderByStringClause
10 Name: AggregateOrderByStringClause
11 NumberOfEmployees: AggregateOrderByNumberClause
12 OperatingHours: OperatingHours_OrderBy
13 Owner: User_OrderBy
14 OwnerId: NoFunctionAggregateOrderByClause
15 Ownership: AggregateOrderByStringClause
16 Parent: Account_OrderBy
17 ParentId: NoFunctionAggregateOrderByClause
18}The main types include:
AggregateOrderByStringClause - Defines aggregate functions used by fields of these types:
AggregateOrderByNumberClause - Defines aggregate functions used by fields of these types:
NoFunctionAggregateOrderByClause - Defines how null values are returned and how sorting order are used by fields of these types:
The AggregateOrderByStringClause type has several enumeration types.
1type AggregateOrderByStringClause {
2 function: AggregateOrderByStringFunction
3 nulls: NullsOrder
4 order: ResultsOrder
5}Pass these types to the orderBy argument in the aggregate field.
function - The aggregate function to apply to the filter.nulls - Orders null records either first or last.order - Order the aggregate results by ascending or descending order.The AggregateOrderByStringFunction enum values define aggregate functions for string fields like date, email, or Url and so on.
1enum AggregateOrderByStringFunction {
2 COUNT
3 COUNT_DISTINCT
4 MAX
5 MIN
6}Use these values with string fields.
COUNT - Returns the number of rows matching the query criteria.COUNT_DISTINCT - Returns the number of distinct non-null field values matching the query criteria.MAX - Returns the maximum value of a field.MIN - Returns the minimum value of a field.The AggregateOrderByNumberClause type has several enumeration types.
1type AggregateOrderByNumberClause {
2 function: AggregateOrderByNumberFunction
3 nulls: NullsOrder
4 order: ResultsOrder
5}Pass these types to the orderBy argument in the aggregate field.
function - The aggregate function to apply to the filter.nulls - Orders null records either first or last.order - Order the aggregate results by ascending or descending order.The NoFunctionAggregateOrderByClause type has several enumeration types.
1type NoFunctionAggregateOrderByClause {
2 nulls: NullsOrder
3 order: ResultsOrder
4}Pass these types to the orderBy argument in the aggregate field.
nulls - Orders null records either first or last.order - Order the aggregate results by ascending or descending order.The AggregateOrderByNumberFunction enum values define aggregate functions for number fields like double, long, percent and so on.
1enum AggregateOrderByNumberFunction {
2 AVG
3 COUNT
4 COUNT_DISTINCT
5 MAX
6 MIN
7 SUM
8}Use these values with numeric fields.
AVG - Returns the average value of a field.COUNT - Returns the number of rows matching the query criteria.COUNT_DISTINCT - Returns the number of distinct non-null field values matching the query criteria.MAX - Returns the maximum value of a field.MIN - Returns the minimum value of a field.SUM - Returns the total sum of a numeric field.The NullsOrder enumeration type specifies the order in which nulls appear in the result set. By default, null values are sorted first.
1enum NullsOrder {
2 FIRST
3 LAST
4}Use these values in the orderBy argument.
FIRST - Order the null values first. This is the default.LAST - Order the null values last.The ResultsOrder enumeration type specifies whether the results are ordered in ascending or descending order. By default, the result is ordered in ascending order.
1enum ResultsOrder {
2 ASC
3 DESC
4}Use these values in the orderBy argument.
ASC - Ascending order (default)DESC - Descending orderSome fields like CreatedBy and Owner correspond to a _OrderBy type, which contains additional fields.
1type User_GroupBy {
2 AboutMe: AggregateOrderByStringClause
3 Account: Account_OrderBy
4 AccountId: NoFunctionAggregateOrderByClause
5 Contact: Contact_OrderBy
6 NumberOfFailedLogins: AggregateOrderByNumberClause
7 # Other User_OrderBy fields
8}SOQL and SOSL Reference: Date Functions