错误:将表达式转换为数据类型nvarchar的算术溢出错误。
UPDATE [dbo].ForecastAccuracyKeyAccounts
SET ThreeMonthPercent = ((Actual - ThreeMonthForecast) / Actual) * 100, SixMonthPercent = ((Actual - SixMonthForecast) / Actual) * 100,
NineMonthPercent = ((Actual - NineMonthForecast) / Actual) * 100
WHERE Actual != 0
因为,我除以实际,我想确保实际不等于零。但是当我在WHERE CLAUSE中添加语句时,我无法摆脱错误。
答案 0 :(得分:1)
也许试试ISNULL
UPDATE [dbo].ForecastAccuracyKeyAccounts
SET ThreeMonthPercent = ((Actual - ISNULL(ThreeMonthForecast,0)) / Actual) * 100,
SixMonthPercent = ((Actual - ISNULL(SixMonthForecast,0)) / Actual) * 100,
NineMonthPercent = ((Actual - ISNULL(NineMonthForecast,0)) / Actual) * 100
WHERE Actual != 0