我无法弄清楚这段代码有什么问题。在 Where 子句中添加 Case 语句之前,查询工作正常,但是当我添加它时,我得到了那个错误。如果有人可以帮助我,我将不胜感激!!
这是案例陈述
CASE
WHEN (GETDATE()< '2013-06-30 00:00:00.000' AND GETDATE() >= '2013-04-01 00:00:00.000') THEN
CASE WHEN (TargetStartDt >= '2013-04-01 00:00:00.000' AND TargetStartDt < '2013-06-30 00:00:00.000') THEN (JobStatus = 'Approved' OR JobStatus = 'Closed(Filled)')
END
WHEN (GETDATE() < '2013-09-30 00:00:00.000' AND GETDATE() >= '2013-07-01 00:00:00.000') THEN
CASE WHEN TargetStartDt < '2013-06-30 00:00:00.000' THEN (JobStatus = 'Approved' OR JobStatus = 'Closed(Filled)' OR JobStatus = 'Closed(Not Filled)')
WHEN (TargetStartDt >= '2013-07-01 00:00:00.000' AND TargetStartDt < '2013-09-30 00:00:00.000') THEN (JobStatus = 'Approved' OR JobStatus = 'Closed(Filled)')
END
WHEN GETDATE() < '2013-12-31 00:00:00.000' AND GETDATE()>= '2013-10-01 00:00:00.000' THEN
CASE WHEN TargetStartDt < '2013-09-30 00:00:00.000' THEN (JobStatus = 'Approved' OR JobStatus = 'Closed(Filled)' OR JobStatus = 'Closed(Not Filled)')
WHEN (TargetStartDt >= '2013-10-01 00:00:00.000' AND TargetStartDt < '2013-12-31 00:00:00.000') THEN (JobStatus = 'Approved' OR JobStatus = 'Closed(Filled)')
END
--ELSE (JobStatus = 'Approved' OR JobStatus = 'Closed(Filled)' OR JobStatus = 'Closed(Not Filled)')
END
太感谢了!!