Specifying column aliases

When you want to control the name of the generated item to represent a particular column or expression in a query, use the AS keyword to specify an alias for that column.

For example, you could specify the query as:

     select min(salary) as min_salary, max(salary) as max_salary from employee

which would result in a type tree containing a Row with two columns representing the result of the SQL MIN and MAX functions. In the type tree, the items created to represent the results of these functions would be min_salary and max_salary. An example of this follows.

You can also use the AS keyword to specify an alias for a column having a name containing any of the characters that are invalid in a type name. Or, you can specify an alias for a column having a name longer than 32 bytes in UTF-8 encoding, which is the limit for the size of a type name.

The following example results in a type tree having a Row with three columns.

Select SomeReallyReallyReallyLongColumnName AS 
SomeLongColumnName, 
      1st-Payment AS Payment#1, 
      2nd-Payment AS Payment#2
      from some_table

The items created to represent the results of this query would be SomeLongColumnName, Payment#1, and Payment#2.