Dual Inner Join Query taking forever to run
i would like to runa a query to get some simple stats on our database but it returns the following error. can someone advise me on how to fix it?
query =
SELECT tblSchemes.Clientid, count(clientid), count(insscheme)
FROM tblSchemes
INNER JOIN tblclaims_liberty ON tblClaims_liberty.AgentCode = tblSchemes.ClientID
INNER JOIN tblPolicys_liberty ON tblSchemes开发者_如何转开发.Scheme = tblPolicys_liberty.InsScheme
GROUP BY tblSchemes.Clientid
Error returned =
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.
Many thanks in advance.
Adam
You may be exceeding the limit on COUNT, which returns an integer. Try using COUNT_BIG instead as it returns a bigint.
I would suspect a data type mismatch between some of the join fields. It is trying to convert something and that seems the most logical place.
精彩评论