1

这是我的简化查询

SELECT FILTER_IS_LONGS FROM PO_OPEN_FINAL_REPORT 
WHERE FILTER_IS_LONGS in( CASE WHEN testVar = 1 then 'Y' else 'N','Y' END )

我收到“缺少关键字”错误。

查询基本上应该根据 testVar 的值生成 IN('Y') 或 IN('N','Y') 的 IN() 子句

我想这与逃避'N','Y'任何帮助有关

4

2 回答 2

1

关于什么

SELECT FILTER_IS_LONGS FROM PO_OPEN_FINAL_REPORT 
WHERE 
(case 
when testvar=1 and FILTER_IS_LONGS in ('Y') then 1 
when testvar<>1 and FILTER_IS_LONGS in ('Y','N') then 1 
else 0) = 1
于 2013-11-13T15:54:19.650 回答
1

完全未经测试,只是给你一个想法:

SELECT FILTER_IS_LONGS
FROM PO_OPEN_FINAL_REPORT 
WHERE (testVar=1 AND FILTER_IS_LONGS='Y')
OR (testVar<>1 AND FILTER_IS_LONGS IN ('N','Y'))

它可能与以下内容相同:

SELECT FILTER_IS_LONGS
FROM PO_OPEN_FINAL_REPORT 
WHERE FILTER_IS_LONGS='Y'
OR (testVar<>1 AND FILTER_IS_LONGS='N')
于 2013-11-13T16:00:33.613 回答