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

zhangchunge 2013-09-06 01:17:47
在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

我知道是在求平均值的时候出现错误,可是不知道怎么样修改
...全文
114 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangchunge 2013-09-06
  • 打赏
  • 举报
回复
AndyHang 太有才了,超喜欢你,谢谢了啊
Andy__Huang 2013-09-06
  • 打赏
  • 举报
回复
不知道你这个值td1是多少? CONVERT(decimal(5,2), td1) 改为 CONVERT(decimal(18,2), td1)
Andy__Huang 2013-09-06
  • 打赏
  • 举报
回复
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

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧