为什么在关键字关键字附近会出现错误,即
Error code -1, SQL state 42X01: Syntax error: Encountered "BETWEEN" at line 10, column 34.
为什么会发生这种想法?
select c.CustomerCode AS 会员ID, c.LastName || ' ' || c.FirstName AS 姓名, c.MobilePhoneNumber AS 手机号码 from
customer c
where
case when
cast( { fn TimeStampAdd(SQL_TSI_YEAR, (YEAR(CURRENT_DATE) - YEAR(c.DOB)), c.DOB) } as date) < CURRENT_DATE
then
{ fn TRIM(CAST(CAST(YEAR(CURRENT_DATE)+1 AS CHAR(4)) AS VARCHAR(4))) } || '-' ||
{ fn TRIM(CAST(CAST(MONTH(c.DOB) AS CHAR(2)) AS VARCHAR(2))) } || '-' ||
{ fn TRIM(CAST(CAST(DAY(c.DOB) AS CHAR(2)) AS VARCHAR(2))) }
BETWEEN CURRENT_DATE
AND cast ({ fn TIMESTAMPADD(SQL_TSI_DAY, +7 , CURRENT_DATE) } as date)
else
{ fn TRIM(CAST(CAST(YEAR(CURRENT_DATE) AS CHAR(4)) AS VARCHAR(4)))} || '-' ||
{ fn TRIM(CAST(CAST(MONTH(c.DOB) AS CHAR(2)) AS VARCHAR(2))) } || '-' ||
{ fn TRIM(CAST(CAST(DAY(c.DOB) AS CHAR(2)) AS VARCHAR(2))) }
BETWEEN CURRENT_DATE
AND cast ({ fn TIMESTAMPADD(SQL_TSI_DAY, +7 , CURRENT_DATE) } as date)
end
group by c.CustomerCode, c.LastName, c.FirstName, c.MobilePhoneNumber;
答案 0 :(得分:0)
我在日期/时间条款周围添加了大括号,解决了它