Search code examples
decimaloverflowteradatadivisiondivide

Teradata: Division and large decimals


I'm trying to divide two decimal(15,2) numbers and return a high precision decimal of 15 places, but I keep getting the [2616] Numeric overflow error on anything beyond 10 decimal places, is there another way to write this to achieve a decimal result of 15 places right of the period?

select (cast(19983.74 as decimal(15,2))*1.0000000000000)/(cast(15897.40 as decimal(15,2))*1.0000000000000)


Solution

  • For more complex calculations I prefer casting the 1st operand to NUMBER, this results in the maximum possible precision:

    SELECT Cast(19983.74 AS NUMBER)/15897.40
    
    1.25704454816510875992300627775611106219
    

    Finally cast back to whatever you need:

    SELECT Cast(Cast(19983.74 AS NUMBER)/15897.40 AS DECIMAL(38,15))
    
    1.257044548165109