So 3 variables x, y and z all defined as DECIMAL (9, 5) (i.e 99,999.99999)
What is the resultant datatype from this calulation
(x * y) / z
Starting with the multiplication inside the brackets
Precision = p1 + p2 + 1 = 9 + 9 + 1 = 19
Scale = s1 + s2 = 10
So now we have a decimal (19, 10) divided by a decimal (9, 5)
Precision = p1 - s1 + s2 + max(6, s1 + p2 + 1) = 19 - 5 + 5 + max(6, 5 + 9 + 1) = 19 + 15 = 34
Scale = max(6, s1 + p2 + 1) = 15
So no, I believe it will be a DECIMAL (34, 15)
Make the original variables decimal (10, 6) to add more precision and you come out with a decimal (38, 17).
One more on the precision and it will overflow, and would not be able to reverse the calculation accurately.