将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