2016-06-24 65 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