我试图通过使用Case When函数将某些雇员分组到一个程序中。但是,我遇到了(缺少运算符)语法错误,似乎找不到问题。
SELECT i360.LOCALDAY, i360.SalesID, i360.ACDID, i360.Employee, i360.Supervisor, i360.Manager, i360.Campaign, i360.Employee_Org,
CASE
WHEN i360.Supervisor = "Bell, Barry"
OR i360.Supervisor = "Call, Jessica"
OR i360.Supervisor = "Carico, Nicole"
OR i360.Supervisor = "Casse, Jennifer"
OR i360.Supervisor = "Edwards, Billy"
OR i360.Supervisor = "Gregory, Angie"
OR i360.Supervisor = "Huffman, Wes"
OR i360.Supervisor = "Kelly, Jessica"
OR i360.Supervisor = "Lyall, Brandy"
THEN "Interior_Supervisors"
WHEN i360.Supervisor = "Metcalfe, Cameron"
OR i360.Supervisor = "Miller, Stephanie"
OR i360.Supervisor = "Ruggles, John"
OR i360.Supervisor = "Shobe, Nathaniel"
OR i360.Supervisor = "Simms, Aaron"
OR i360.Supervisor = "Spruill, April"
OR i360.Supervisor = "Stanfield, Chad"
OR i360.Supervisor = "Woods, Edward"
THEN "Core_Supervisors"
ELSE "Exterior_Supervisors"
END as Program,
FROM t_i360 AS i360 INNER JOIN t_cms AS cms ON (cms.LOCALDAY=i360.LOCALDAY) AND (cms.LOGID=i360.ACDID);
答案 0 :(得分:1)
您应使用in
和switch
:
switch(i360.Supervisor in ("Bell, Barry", "Call, Jessica", "Carico, Nicole", . . .),
"Interior_Supervisors",
i360.Supervisor in ("Metcalfe, Cameron", "Miller, Stephanie", "Ruggles, John", . . . ),
"Core_Supervisors",
1=1,
"Exterior_Supervisors"
) as Program,