Data types of result columns

Each column of the result of SELECT acquires a data type from the expression from which it is derived.

When the expression is: The data type of the result column is:
the name of any numeric column the same as the data type of the column, with the same precision and scale for decimal columns.
an integer constant INTEGER or BIGINT (if the value of the constant is outside the range of INTEGER, but within the range of BIGINT).
a decimal or floating-point constant the same as the data type of the constant, with the same precision and scale for decimal constants.
the name of a DECFLOAT(7) variable DECFLOAT(16)
the name of any numeric variable the same as the data type of the variable, with the same precision and scale for decimal variables. If the data type of the variable is not identical to an SQL data type (for example, DISPLAY SIGN LEADING SEPARATE in COBOL), the result column is decimal.
an expression the same as the data type of the result, with the same precision and scale for decimal results as described under Expressions.
any function the data type of the result of the function. For a built-in function, see Built-in functions to determine the data type of the result. For a user-defined function, the data type of the result is what was defined in the CREATE FUNCTION statement for the function.
the name of any string column the same as the data type of the column, with the same length attribute.
the name of any string variable the same as the data type of the variable, with a length attribute equal to the length of the variable. If the data type of the variable is not identical to an SQL data type (for example, a NUL-terminated string in C), the result column is a varying-length string.
a character-string constant of length n VARCHAR(n)
a graphic-string constant of length n VARGRAPHIC(n)
Start of changethe name of an XML column or variableEnd of change Start of changeXMLEnd of change
the name of a datetime column, or an ILE RPG compiler or an ILE COBOL compiler datetime host variable the same as the data type of the column or variable.
the name of a distinct type column the same as the distinct type of the column, with the same length, precision, and scale attributes, if any.
the name of a datalink column a datalink, with the same length attribute.
the name of a row ID column or a row ID variable ROWID