The table below shows the resulting data type for all aggregate functions based on the input data type (only numeric input types are listed). For aggregate functions that only accept numeric values as input, if a non-numeric value is passed to the function, it is implicitly converted to a numeric value automatically. For aggregate functions that accept non-numeric inputs, the data type of result will match the data type of the input value.
*1 - Precision & Scale are calculated as follows:
P & S represent the scale & precision of the input respectively:
if S < 6, output precision = P + 6 - S, else output precision = P.
if S < 6, output scale = 6 else output scale = S.
*2 - Precision & Scale are calculated as follows:
P & S represent the scale & precision of the input respectively:
If P+6 < 11, output precision = 11 else if P+6 > 37, output precision = 37 else output precision = P+6.
output scale = S.