Selecting derived columns
In a SELECT statement, you can select columns that are not actual columns in a table. Instead, you can specify columns
that are derived from a constant, an expression, or a function.
Example: SELECT with an expression
This SQL statement generates a result table in which the second column is a derived column that is generated by adding the values of the SALARY, BONUS, and COMM columns.SELECT EMPNO, (SALARY + BONUS + COMM)
FROM DSN8D10.EMP;
Derived columns in a result table, such as (SALARY + BONUS + COMM), do not have names. You can use the AS clause to give a name to an unnamed column of the result table. For information about using the AS clause, see Naming result columns.
What to do next
To order the rows in a result table by the values in a derived column, specify a name for the column by using the AS clause, and specify that name in the ORDER BY clause. For information about using the ORDER BY clause, see Ordering the result table rows.