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 + 5ASC
orDESC
controls direction. Default is ascending. Sort is lexicographic.NULLS FIRST
orNULLS LAST
controls null behavior. Default isNULLS 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.
Updated about 4 years ago