我有以下代码。目的是获取 AML_TYP_CD 字段中的数据,这是他们完成的教育水平。20 和 25 与 30/35/ 40/45 相同,我需要编写一个案例语句将它们一起计数,这样 25 将返回为 20 等,然后还有大约 50 个其他教育水平代码我需要消除。最好的方法是什么,因为我正在编写的 CASE 语句不起作用。CASE 语句将进入 SELECT 子句,我写的那个不起作用的是
CASE WHEN (AML_TYP_CD) = '20' OR '25' THEN Bachelors ELSE NULL END) As Bach_Degree
其余的代码是:
SELECT dbo.TACCPLI.SYS_EMP_ID_NR, MAX(dbo.TACCPLI.AML_TYP_CD) AS DEG
FROM dbo.TACCPLI INNER 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