算术溢出:"Converting numeric to data type numeric" 错误
Arithematic Overflow : "Converting numeric to data type numeric" error
有两列的数据类型为小数 (16,4)
- 拥有股份
- 总发行量
我正在尝试使用这两列计算百分比,然后将其转换为小数 (7,4)。
正在使用的代码:
Convert(Decimal(7,4),Case when OwnedShares = 0 or TotalOutstandingShares = 0 then 0 else ((OwnedShares/TotalOutstandingShares)*100) end)
我收到错误消息:'Arithmetic overflow error converting numeric to data type numeric.'
谁能帮我弄清楚我哪里出错了?
如果您遇到算术溢出错误,则可能是您的百分比计算返回了至少一条大于 100.0000(或 100%)的记录。尝试增加 decimal's precision 以增加可以存储的位数,直到错误不再发生,例如DECIMAL(8,4) 或更高。
有两列的数据类型为小数 (16,4)
- 拥有股份
- 总发行量
我正在尝试使用这两列计算百分比,然后将其转换为小数 (7,4)。
正在使用的代码:
Convert(Decimal(7,4),Case when OwnedShares = 0 or TotalOutstandingShares = 0 then 0 else ((OwnedShares/TotalOutstandingShares)*100) end)
我收到错误消息:'Arithmetic overflow error converting numeric to data type numeric.'
谁能帮我弄清楚我哪里出错了?
如果您遇到算术溢出错误,则可能是您的百分比计算返回了至少一条大于 100.0000(或 100%)的记录。尝试增加 decimal's precision 以增加可以存储的位数,直到错误不再发生,例如DECIMAL(8,4) 或更高。