2016-06-24 66 views
0

我试图在excel输出的代码中搜索并显示下面提到的以下问题。 由于我的excel电子表格有LABELDATA作为两列,问题出现在名为LABEL的列下,而其相关YES/NO答案出现在名为DATA的列下。SQL(Where IN)子句的用法

前三个问题应该显示在Excel工作表中,前提是答案是'NO'!

WHERE Label IN ('Is the price adequate? ' AND Data='No', 
       'Were the proper measures taken prior? ' AND Data='No', 
       'Is the incident reported? ' AND Data='No', 
       'Did the both prices match?' , 
       'Learning Methods', 
       'Next actions Required','Final feedback') 

执行时,上面的代码抛出了输出中的所有问题,无论它是否是/否

+0

目前还不清楚是什么你'试图去做,但你可能需要使用CASE表达式。 –

+0

对生成的GUID进行排序并更新前10名? – Will

+0

我发布了我正在处理的实际查询 – Swathi

回答

2

看起来你需要像

WHERE 
    (
     Label IN ('Is the price adequate? ', 
       'Were the proper measures taken prior? ', 
       'Is the incident reported? ' 
      ) 
     AND Data='No' 
    ) 
    or 
    (
     Label IN ('Did the both prices match?' , 
        'Learning Methods', 
        'Next actions Required', 
        'Final feedback' 
       ) 
    ) 
+0

这是选择列下的所有值。实际上我只需要'30','40','50'和'10'和'20'这两个值,只有当它的回答是否定的时候 – Swathi

+0

嗯......看起来我错过了一些东西。条件应该与'和'结合,而不是'或'逻辑运算符。 –

+0

我试过AND运算符。它仍然是一样的 – Swathi