Window ordering

When you order data in a window, you are actually ordering the data in each of its partitions. To order data in a window, use the ORDER BY clause to specify the columns that are known as the ordering columns.

<window order clause> ::= ORDER BY <sort specification list>
<sort specification list> ::= <sort specification> [ { , <sort specification> } …]
<sort specification> ::= <sort key> [ <ordering specification> ]
<sort key> ::= <value_expression>
<ordering specification> ::= [ASC | DESC] [NULLS {FIRST | LAST}]

If your data contains nulls, all null values are considered to be lower than any non-null value. This means that for an ascending sort, nulls display first in the output, or for a descending sort, they display last. You can control the null sorting by using NULLS {FIRST | LAST}.