gpt4 book ai didi

sql-server - SQL 抛出算术溢出错误

转载 作者:行者123 更新时间:2023-12-04 00:04:54 24 4
gpt4 key购买 nike

我在运行简单的聚合函数时收到“算术溢出错误将表达式转换为数据类型 int”错误(请参阅下面的代码)。当我缩减日期范围时,我可以看到结果实际上超过了 INT 数据类型限制......我已经尝试将整个表达式转换为 BIGINT,但没有成功。有人知道我该如何解决这个问题吗?

所有这 3 个查询都会抛出上述相同的错误:

Select  (SUM(ACDTalkTimeInSec) + SUM(TotAcwTimeInSec) + SUM(HoldTimeInSec)) as AHT
From ColTelephony.dbo.vwACDSkillCombined acd
Where WorkDte between '1/2/2018' AND '10/5/2018'

Select CAST(Cast(SUM(ACDTalkTimeInSec) AS BIGINT) + CAST(SUM(TotAcwTimeInSec) AS BIGINT) + CAST(SUM(HoldTimeInSec) AS BIGINT) AS BIGINT) as AHT
From ColTelephony.dbo.vwACDSkillCombined acd
Where WorkDte between '1/2/2018' AND '10/5/2018'

Select Cast(((SUM(ACDTalkTimeInSec) + SUM(TotAcwTimeInSec) + SUM(HoldTimeInSec))) AS BIGINT) as AHT
From ColTelephony.dbo.vwACDSkillCombined acd
Where WorkDte between '1/2/2018' AND '10/5/2018'

最佳答案

SMor 在评论中回答了它,但这里是 sql:

Select SUM(CAST(ACDTalkTimeInSec AS BIGINT)) + SUM(CAST(TotAcwTimeInSec AS BIGINT)) 
+ SUM(CAST(HoldTimeInSec AS BIGINT)) as AHT
From ColTelephony.dbo.vwACDSkillCombined acd
Where WorkDte between '1/2/2018' AND '10/5/2018'

如果 SMor 发布了他们的答案,则接受它。我没有测试代码,所以请原谅任何拼写错误。

关于sql-server - SQL 抛出算术溢出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52726382/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com