我试图获得一个列总数,但是当我运行这个查询时,我得到了以下错误。有什么建议吗?
SELECT SUM(Size) as total
FROM AllDocs
Where DirName LIKE 'sites/test/test%'
ERROR:
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.
Warning: Null value is eliminated by an aggregate or other SET operation.
发布于 2009-08-03 15:10:05
虽然你的所有尺寸都可以放入INT
(最高可达2^31 - 1
),但它们的SUM
不能。
将它们转换为BIGINT
SELECT SUM(CAST(Size AS BIGINT)) as total
FROM AllDocs
WHERE DirName LIKE 'sites/test/test%'
https://stackoverflow.com/questions/1222877
复制相似问题