我正在尝试将此作为检查FISCAL_START
日期范围的测试运行。
SELECT FISCAL_START,DESCRIPTION,
(
CASE FISCAL_START
WHEN FISCAL_START = '2014-03-31' THEN DESCRIPTION
WHEN FISCAL_START = '2014-09-29' THEN DESCRIPTION
ELSE 'Test Failed'
END )
FROM GL_PERIOD
一直出错,缺少关键字。
您混淆了case
表达式语法。
你想要的可能是:
SELECT FISCAL_START, DESCRIPTION,
CASE WHEN FISCAL_START >= DATE'2014-03-31'
AND FISCAL_START <= DATE'2014-09-29' THEN DESCRIPTION
ELSE 'Test Failed'
END
FROM GL_PERIOD
可简化为:
SELECT FISCAL_START, DESCRIPTION,
CASE WHEN FISCAL_START BETWEEN DATE'2014-03-31' AND DATE'2014-09-29' THEN DESCRIPTION
ELSE 'Test Failed'
END
FROM GL_PERIOD