GREATEST Result Type - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

If the input arguments are numeric types, the function determines which argument has the highest precedence, converts the other arguments to that data type, and returns that data type.

If the data type is DECIMAL/NUMERIC and the precision and scale of the input arguments are different, the precision and scale of the return type is set to achieve the maximum precision possible. For example, if the input arguments are DECIMAL(6,3), DECIMAL(7,4), and DECIMAL(8,7), the return type needs three digits to the left of the decimal point and seven digits to the right of the decimal point to avoid reduction in precision. The return data type is set to DECIMAL(10,7).

If the data type is fixed point NUMBER and the precision is less than or equal to 38, the precision and scale of the return type are calculated with the same method used for DECIMAL/NUMERIC. However, if the precision is greater than 38, the return type is changed to NUMBER(*) to avoid loss of accuracy. If the data type is floating point NUMBER, the return type is NUMBER(*).

If the input arguments are character types, the function converts the 2nd through 10th arguments to the data type of the 1st argument and returns the type as VARCHAR in the character set of the 1st argument.

If the input arguments are DATE types, the function returns a DATE type.

If the input arguments are TIMESTAMP types, the function returns a TIMESTAMP type. If the first parameter includes an explicit time zone, the result includes a time zone.

If any of the input arguments is NULL, the function returns NULL.