这里的前两个查询工作正常:
SELECT * FROM sys_calendar.calendar
WHERE calendar_date BETWEEN CAST('2012-06-01' AS DATE) - 365
AND CAST('2013-06-01' AS DATE) - 1;
SELECT * FROM sys_calendar.calendar
WHERE calendar_date IN ('2012-06-01', '2013-06-03');
但是,接下来的两个查询会引发错误
选择失败。[3706] 语法错误:预期介于 ')' 和 ',' 之间。
似乎CAST
正在抛弃 IN 子句,但我不明白为什么。这里发生了什么?
SELECT * FROM sys_calendar.calendar
WHERE calendar_date IN (CAST('2012-06-01' AS DATE)
, CAST('2013-06-03' AS DATE));
SELECT * FROM sys_calendar.calendar
WHERE calendar_date IN (CAST('2012-06-01' AS DATE) - 365
, CAST('2013-06-01' AS DATE) - 1);