我正在尝试获取列总数,但是当我运行此查询时,我收到以下错误。有什么建议吗?
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.
答案 0 :(得分:37)
虽然您的所有尺码都可以放入INT
(最多2^31 - 1
),但他们的SUM
却不能。{/ p>
将它们投放到BIGINT
:
SELECT SUM(CAST(Size AS BIGINT)) as total
FROM AllDocs
WHERE DirName LIKE 'sites/test/test%'