第一种情况将在查询中进行编译,但是当我添加第二种情况时,会出现以下错误"' program'"附近的语法错误。如何在更新中使用IN子句的列表。 2008R
academic_session = CASE PC.KEY5
WHEN 'AGS' THEN 'AGS'
WHEN 'TRD' THEN 'Traditional'
END,
program = CASE PC.KEY3
WHEN PC.KEY3 IN ('FF-AGS', 'FF-TRD', 'TR-AGS', 'CH-TRD', 'CO-TRD', 'RE-TRD', 'TR-TRD', 'WDVW') THEN 'Undergraduate'
WHEN PC.KEY3 = 'CROSS' THEN 'CROSS'
WHEN PC.KEY3 = 'GR-AGS' THEN 'Graduate'
WHEN PC.KEY3 IN ('ND-AGS', 'ND-TRD') THEN 'Non Degree Seeking'
END program,
程序'附近的语法不正确。
将每个条件发布在单独的行上并进行编译。
program = CASE PC.KEY3
--WHEN PC.KEY3 IN ('FF-AGS', 'FF-TRD', 'TR-AGS', 'CH-TRD', 'CO-TRD', 'RE-TRD', 'TR-TRD', 'WDVW') THEN 'Undergraduate' --"Incorrect syntax near the keyword 'IN'"
WHEN 'FF-AGS' THEN 'Undergraduate'
WHEN 'FF-TRD' THEN 'Undergraduate'
WHEN 'TR-AGS' THEN 'Undergraduate'
WHEN 'CH-TRD' THEN 'Undergraduate'
WHEN 'CO-TRD' THEN 'Undergraduate'
WHEN 'RE-TRD' THEN 'Undergraduate'
WHEN 'TR-TRD' THEN 'Undergraduate'
WHEN 'WDVW' THEN 'Undergraduate'
WHEN 'CROSS' THEN 'CROSS'
WHEN 'GR-AGS' THEN 'Graduate'
WHEN 'ND-AGS' THEN 'Non Degree Seeking'
WHEN 'ND-TRD' THEN 'Non Degree Seeking'
END,
答案 0 :(得分:1)
尝试以下
academic_session = CASE PC.KEY5
WHEN 'AGS' THEN 'AGS'
WHEN 'TRD' THEN 'Traditional'
ELSE NULL
END,
program = CASE WHEN PC.KEY3 IN ('FF-AGS', 'FF-TRD', 'TR-AGS', 'CH-TRD', 'CO-TRD', 'RE-TRD', 'TR-TRD', 'WDVW') THEN 'Undergraduate'
CASE WHEN PC.KEY3 = 'CROSS' THEN 'CROSS'
CASE WHEN PC.KEY3 = 'GR-AGS' THEN 'Graduate'
CASE WHEN PC.KEY3 IN ('ND-AGS', 'ND-TRD') THEN 'Non Degree Seeking'
ELSE NULL
END ,