在此代码的第1行获取错误...
Select COUNT(MEM_REL) As MemberSub, CLM_CC2 As GroupNum
From Impact.dbo.tbl_mem, Impact.dbo.tbl_clm
Where MEM_REL = '01'
Group by CLM_CC2
错误是:
MSg 8815, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int
答案 0 :(得分:2)
尝试为查询引入正确的关系,现在您将获得两个表的笛卡尔积。例如,使用关键字error BC36716: Visual Basic 12.0 does not support 'nameof' expressions.
代替逗号,
来连接两个表,然后定义要连接这些表的列的关系。
完成上述操作后,返回的行数将大幅减少,以下查询可能会有效,如果您在以下查询中有超过22亿行,则可能需要使用JOIN
函数而不是只是COUNT_BIG()
COUNT()
使用COUNT_BIG()
查询Select COUNT(MEM_REL) As MemberSub
, CLM_CC2 As GroupNum
From Impact.dbo.tbl_mem
INNER JOIN Impact.dbo.tbl_clm
ON dbo.tbl_mem.[ReferencingColumn] = dbo.tbl_clm.[ReferencingColumn]
Where MEM_REL = '01'
Group by CLM_CC2