invantive documentationpart of invantive cloud
Invantive Support ForumsLog In / Sign Up

Sort Rows

The $orderby system query option states the order of the rows. Each column is optionally followed by asc for ascending or desc for descending; ascending is the default.

One Column

GET .../odata4/ExactOnlineREST.Financial.GLAccountsBulk@eol?$orderby=Code

Several Columns

The columns are separated by commas and applied from left to right:

GET .../odata4/ExactOnlineREST.Financial.GLAccountsBulk@eol?$orderby=DivisionName asc,Code desc

Together With a Sample

An order combined with $top is the way to ask for the largest or the smallest rows rather than for an arbitrary handful:

GET .../odata4/ExactOnlineREST.Financial.GLAccountsBulk@eol?$orderby=Code desc&$top=10

The order is applied before the limit, so this answers the ten highest codes.

When Sorting Is Better Left to the Client

A report which sorts the rows itself, as Microsoft Power BI does, gains nothing from $orderby, and on some platforms an order costs a slower query. Ask for an order where the order decides which rows are retrieved, as in the example above, and leave it out where it only decides how they are displayed.

An order cannot be combined with a grouping. A grouped answer is sorted by the client; see Group and Aggregate Rows.

Release Notes