title: Iff condition Access to SQL syntax
body: <p>I have an access query that I have recreate in SQL.</p>
  
  <p>Access:</p>
  
  <pre><code>   SELECT Columns , 
  
  IIf([Col1]="X",IIf([COL2]&lt;&gt;"XXXX",1,0)) AS NEWCOL1, 
  
  IIf([COL2] Not In ("HHH","GGG"),1,0) AS [NEWCOL2], 
  
  IIf(([NEWCOL1]=1) Or ([NEWCOL2]=1),1,0) AS NEWCOL3 
  
  FROM [TABLE]
  
  WHERE ((([TABLE].COL2)&lt;&gt;"XXXX")) OR ((([TABLE].COL2)&lt;&gt;"HHH" And ([TABLE].COL2)&lt;&gt;"GGG"));
  </code></pre>
  
  <p>In SQL :</p>
  
  <pre><code>SELECT Columns , 
  
  "NEWCOL1" =
  CASE WHEN ([COL1]='X' AND COL2&lt;&gt; 'XXXX') THEN 1 
  ELSE 0
  END,
  
  "NEWCOL2" =
  
  CASE WHEN COL2 NOT IN ('HHH','GGG') THEN 1
  ELSE 0
  END ,
  
  IIf(([NEWCOL1]=1) Or ([NEWCOL2]=1),1,0) AS NEWCOL3 
  
  
  FROM [TABLE]
  
  WHERE ((([TABLE].COL2)&lt;&gt;'XXXX')) OR ((([TABLE].COL2)&lt;&gt;'HHH' And ([TABLE].COL2)&lt;&gt;'GGG'));
  </code></pre>
  
  <p>IIf(([NEWCOL1]=1) Or ([NEWCOL2]=1),1,0) AS NEWCOL3</p>
  
  <p>When I use the Newcol1 and newcol2 it throws an error invalid column how could use them maybe in a nested case or iif statement</p>