...
Code Block |
---|
colOrder: ( ASC | DESC ) colNullOrder: (NULLS FIRST | NULLS LAST) orderBy: ORDER BY colName colOrder? colNullOrder? (',' colName colOrder? colNullOrder?)* query: SELECT expression (',' expression)* FROM src orderBy |
...
Note that columns are specified by name, not by position number. However in Hive 0.11.0 and later, columns can be specified by position if hive.groupby.orderby.position.alias is set to true (the default is false).
The default sorting order is ASC. In Hive 2.1.0 and later, specifying the null sorting order for each of the columns in the "order by" clause is supported. The default null sorting order for ASC order is NULLS FIRST, while the default null sorting order for DESC order is NULLS LAST.
Syntax of Sort By
The SORT BY syntax is similar to the syntax of ORDER BY in SQL language.
...