mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-26 16:17:19 -04:00
* Break out 'Limitations' into separate page * Add REST API docs * Restructure commands, functions, and operators refs * Add placeholder for getting started guide * Group 'Syntax', 'Metafields', and 'MV fields' under 'Language' * Add placeholder for Kibana page * Add link from landing page * Apply uniform formatting to ACOS, CASE, and DATE_PARSE function refs * Reword default LIMIT * Add support for COUNT(*) * Move 'Commands' and 'Functions and operators' to individual pages --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
37 lines
905 B
Text
37 lines
905 B
Text
[discrete]
|
|
[[esql-sort]]
|
|
=== `SORT`
|
|
Use the `SORT` command to sort rows on one or more fields:
|
|
|
|
[source,esql]
|
|
----
|
|
include::{esql-specs}/docs.csv-spec[tag=sort]
|
|
----
|
|
|
|
The default sort order is ascending. Set an explicit sort order using `ASC` or
|
|
`DESC`:
|
|
|
|
[source,esql]
|
|
----
|
|
include::{esql-specs}/docs.csv-spec[tag=sortDesc]
|
|
----
|
|
|
|
Two rows with the same sort key are considered equal. You can provide additional
|
|
sort expressions to act as tie breakers:
|
|
|
|
[source,esql]
|
|
----
|
|
include::{esql-specs}/docs.csv-spec[tag=sortTie]
|
|
----
|
|
|
|
[discrete]
|
|
==== `null` values
|
|
By default, `null` values are treated as being larger than any other value. With
|
|
an ascending sort order, `null` values are sorted last, and with a descending
|
|
sort order, `null` values are sorted first. You can change that by providing
|
|
`NULLS FIRST` or `NULLS LAST`:
|
|
|
|
[source,esql]
|
|
----
|
|
include::{esql-specs}/docs.csv-spec[tag=sortNullsFirst]
|
|
----
|