当前位置: 代码迷 >> Sql Server >> 将numeric转换为数据类型numeric时发生算术溢出异常
  详细解决方案

将numeric转换为数据类型numeric时发生算术溢出异常

热度:91   发布时间:2016-04-24 20:32:57.0
将numeric转换为数据类型numeric时发生算术溢出错误
在sql语句中出现这样的错误。
我的SQl语句是select cast(fjh   as   int) as fjh , avg(ABjuedui) as ABjavg  from (select cast(fjh   as   int) as fjh ,abs(CONVERT(decimal(5,2), td1) - CONVERT(decimal(5,2), td2))  as ABjuedui  from fz02time201309 where cplx='44' and CONVERT(char(8), upsj, 108)  between '15:59:59' and '23:59:59' ) DERIVEDTBL GROUP BY fjh  order by fjh

我知道是在求平均值的时候出现错误,可是不知道怎么样修改

------解决方案--------------------
select fjh , avg(ABjuedui) as ABjavg  
from 
(select cast(fjh   as   int) as fjh ,abs(CONVERT(decimal(18,2), td1) - CONVERT(decimal(18,2), td2))  as ABjuedui  
from fz02time201309 
where cplx='44' and CONVERT(char(8), upsj, 108)  between '15:59:59' and '23:59:59' 
) DERIVEDTBL 
GROUP BY fjh  
order by fjh

  相关解决方案