Order By Schema

AVAILABLE API VERSION
API v56.0 and later

Each orderable field on a record, such as on an account, gets a corresponding field on Account_OrderBy with type OrderByClause. The OrderByClause type allows you to specify ascending or descending order, as well as the order of null values.

Orderable fields are linked to InputObject types like OrderByClause, depending on their type, such as User_OrderBy for user fields, or OrderByGeolocation for geolocation fields.

Let's take a look at an example account object that demonstrates how fields map to Account_OrderBy.

The OrderByClause type contains order and nulls enumeration types.

The ResultOrder enumeration type specifies whether the results are ordered in ascending or descending order. By default, the result is ordered in ascending order.

The NullOrder enumeration type specifies the order in which nulls appear in the result set. By default, null values are sorted first.

The order by object has input object fields for each parent relationship the object has. The field has the same name as the parent relationship, and have the OrderBy type corresponding to the object that the relationship points at.

Geolocation fields map to the OrderByGeolocationClause type. Its constituent fields Location__Latitude__s and Location__Longitude__s map to the OrderByClause type.

The DistanceInput type specifies the latitude and longitude fields on a geolocation field.

For more information, see Location-Based Filters.

ORDER BY statement