gpt4 book ai didi

sql-server-2005 - 将表达式转换为数据类型 int 时出现算术溢出错误

转载 作者:行者123 更新时间:2023-12-03 18:29:31 24 4
gpt4 key购买 nike

我在下面的查询中遇到了问题。问题是:

Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type int

问题出在下面的这一行代码中。

INNER JOIN Test t ON a.AccountNO <> t.AccountNo

有什么想法吗?

WITH TEST AS
(
SELECT DISTINCT AccountNo, SUBSTRING(APartyNO, 3, LEN(APartyNo)) AS APartyNoCut
FROM (SELECT DISTINCT AccountNo, APartyNo
FROM prf_BatchItems
WHERE BatchID = 127
AND Code1 = 'DEDF'
AND APartyNo NOT LIKE '04%'
AND ( Left(APartyNo,2) = '02'
OR Left(APartyNo,2) = '03'
OR Left(APartyNo,2) = '07'
OR Left(APartyNo,2) = '08')
GROUP BY AccountNo, APartyNo
UNION
SELECT DISTINCT AccountNo, APartyNo
FROM prf_BatchItemAdditionalAPartyNos
WHERE BatchID = 127
GROUP BY AccountNo, APartyNo) a
)
SELECT Code2, TypeName, CallTypeName, --SUM([Count]),
SUM(Duration), SUM(CostGrossExGST)
FROM
(
SELECT 'WITHOUT STD' AS Type,
Code2, b.TypeName, CallTypeName,
--SUM([COunt]) AS Count,
SUM(DurationSecond) AS Duration,
SUM(a.CostGrossExGSt) AS CostGrossExGST
FROM prf_BatchItems a
INNER JOIN (SELECT * FROM dbo.prf_BillTypeCodes WHERE BillTypeID = 2) b ON a.Code2 = b.BillCodeName
INNER JOIN Test t ON a.AccountNO <> t.AccountNo
where BatchID = 127
AND Code1 = 'DC'
AND ServiceTypeName = 'MobileNet'
AND CallTypeName = 'National Direct Dialled calls'
AND (LEFT(BPartyNo,2) <> '02' AND LEFT(BPartyNo,2) <> '03' OR LEFT(BPartyNo,2) <> '07' OR LEFT(BPartyNo,2) <> '08')
AND BPartyNo NOT LIKE '04%'
AND BPartyNo NOT LIKE '1%'
GROUP BY --a.AccountNo,
Code2, b.TypeName, CallTypeName) zz
GROUP BY Code2, TypeName, CallTypeName

最佳答案

看起来像这一行中的 AccountNO 之一 INNER JOIN Test t ON a.AccountNO <> t.AccountNo不是整数并且有一个不能转换为整数的值

两个表中列的数据类型是什么

关于sql-server-2005 - 将表达式转换为数据类型 int 时出现算术溢出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3445207/

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