Window Order Clause

Specifies how to sort rows that are supplied to the analytic function. If the OVER clause also includes a window partition clause, rows are sorted within each partition.

The window order clause only specifies order within a window result set. The query can have its own ORDER BY clause outside the OVER clause. This has precedence over the window order clause and orders the final result set.

An window order clause also creates a default window frame if none is explicitly specified.


ORDER BY { expression[ sort-qualifiers ] } [,…]


   { ASC | DESC [ NULLS { FIRST | LAST | AUTO } ] }


expression A column, constant, or arbitrary expression formed on columns, on which to sort input rows.
ASC | DESC Specifies the ordering sequence as ascending (default) or descending.

Specifies whether to position null values first or last. Default positioning depends on whether the sort order is ascending or descending:

  • Ascending default: NULLS LAST
  • Descending default: NULLS FIRST

If you specify NULLS AUTO, Vertica chooses the positioning that is most efficient for this query, either NULLS FIRST or NULLS LAST.

If you omit all sort qualifiers, Vertica uses ASC NULLS LAST.

For more information, see:


See Window Ordering in Analyzing Data.