我正在尝试对 CPT 代码进行简单计数,但对为什么会收到错误感到困惑:
消息 245,级别 16,状态 1,行 3 将 varchar 值“J1040”转换为数据类型 int 时转换失败。
这是查询:
SET NOCOUNT ON
SELECT
count(pvp.CPTCode) as CPTcount
from
PatientVisitProcs pvp
JOIN batch b ON pvp.batchid = b.batchid
JOIN patientvisit ar ON pvp.patientvisitid = ar.patientvisitid
WHERE
b.Entry >= ISNULL('09/01/2012','1/1/1900') and b.Entry < dateadd(d, 1, ISNULL('8/31/2012','1/1/3000'))
and pvp.CPTCode in (62311,64484,64493,64494,62310,64479,64480,64490,64491,64492,64633,64634,64635,64636)
AND --Filter on company
(
( ar.CompanyID IN (1725))
)
AND --Filter on facility
(
( ar.FacilityID IN (1460))
)
Group By pvp.CPTCode
With RollUp
向正确方向轻推或快速踢将不胜感激。谢谢!
我相信它来自实际的 CPTCode 列:
CPTCode
80053
80061
83721
85025
81001
84153
Copay
Copay
J0152