我有以下代码。Case语句将列出的数字转换为文本,其余代码转换为NULL,但我一直收到以下错误:CONVERSION FAILED WHEN CONVERTING THE VARCHAR VALUE 'RDG5' TO DATA TYPE INT。RDG5是被转换为NULL的许多代码之一。有什么想法吗?
SELECT dbo.TACCPLI.SYS_EMP_ID_NR, MAX(dbo.TACCPLI.AML_TYP_CD) AS DEG, (CASE WHEN dbo.TACCPLI.AML_TYP_CD IN (20, 25)
THEN 'Associates' WHEN dbo.TACCPLI.AML_TYP_CD IN (30, 35) THEN 'Bachelors' WHEN dbo.TACCPLI.AML_TYP_CD IN (40, 45)
THEN 'Masters' WHEN dbo.TACCPLI.AML_TYP_CD IN (50) THEN 'PhD' ELSE NULL END) AS Degree_Level, dbo.TACCPLI.AML_TYP_CD
FROM dbo.TACCPLI RIGHT OUTER JOIN
(SELECT dbo.v_TMS_employee_HR.GEMSID, dbo.v_TMS_employee_HR.TMS_ID
FROM dbo.v_TMS_employee_HR INNER JOIN
dbo.v_sc17_TMS_Data_Career_Meeting_Rating ON
dbo.v_TMS_employee_HR.TMS_ID = dbo.v_sc17_TMS_Data_Career_Meeting_Rating.Employee_ID
WHERE (LEFT(dbo.v_sc17_TMS_Data_Career_Meeting_Rating.Meeting_Readiness_Rating, 2) IN ('14', '15')) AND
(dbo.v_TMS_employee_HR.Job_Group_Code >= '72') AND (dbo.v_TMS_employee_HR.Job_Group_Code <= '79') AND
(dbo.v_sc17_TMS_Data_Career_Meeting_Rating.Plan_Year = 2012) AND (dbo.v_TMS_employee_HR.Region NOT IN ('12', '13', '16', '17'))
GROUP BY dbo.v_sc17_TMS_Data_Career_Meeting_Rating.Meeting_Readiness_Rating, dbo.v_TMS_employee_HR.GEMSID, dbo.v_TMS_employee_HR.TMS_ID)
AS HPS ON dbo.TACCPLI.SYS_EMP_ID_NR = HPS.TMS_ID
GROUP BY dbo.TACCPLI.SYS_EMP_ID_NR, dbo.TACCPLI.AML_TYP_CD