User GuidesAPI ReferenceRelease Notes
Doc HomeHelp CenterLog In

Order

ORDER sorts the rows of a table by one or more expressions.

ORDER does not change the underlying schema. ORDER does not impact the order of rows in data export.

ORDER BY <expr> (ASC | DESC) (NULLS FIRST | NULLS LAST)

ORDER syntax is as follows:

  • <expr> is usually a column name, such as ID, but it can be any expression, such as ID + 5
  • ASC or DESC controls direction. Default is ascending. Sort is lexicographic.
  • NULLS FIRST or NULLS LAST controls null behavior. Default is NULLS LAST.
  • A clause is <expr (ASC|DESC) (NULLS FIRST | NULLS LAST)>. Multiple clauses can be written, but there must be at least one.
  • Clauses are interpreted from left to right.