17.05 - Column References and ORDER BY - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

Each column_name you specify in an ORDER BY clause must be the name of a column in a relation referenced in the SELECT expression list. The columns named do not have to match the columns in the SELECT expression list.

You can also order on a column_name_alias.

You can specify up to 64 column names.

You cannot specify BLOB or CLOB columns in the column name list because you cannot sort on LOB values.

The column position you specify in an ORDER BY clause must be an unsigned integer that refers to the sequential position of a column in the SELECT expression list. The column position cannot be passed as a parameter, because the parameter is interpreted as an expression and the data is sorted by a constant. You cannot specify BLOB or CLOB columns in the column position list because you cannot sort on LOB values.

For ORDER BY references to UDT columns, the database uses the defined ordering functionality for that UDT to order the result set.

You can specify a scalar subquery as a column expression in the ORDER BY clause of a query.