title: IF/Else/CASE Statement in WHERE clauses
body: <p>I am selecting records from has a column called [tagged], and it's defaulted to Zero.<br>
  My problem is when the <code>@tagged</code> variable is <code>NULL</code>, then I want to select both 0,1 values.  This makes me think I should be doing an <code>IF/ELSE</code>, but my attempts are failing.</p>
  
  <p>--- simple example:</p>
  
  <pre><code>declare @tagged int = NULL
  
  SELECT * 
  FROM [TableName] 
  WHERE datecreated &gt; '2016-01-01' 
  AND tagged = @tagged
  </code></pre>
  
  <hr>
  
  <p>Many DBAs are recommending the CASE clause. 
  But I need help knowing where to add it.</p>
  
  <p>Do I add it inside the Query? </p>
  
  <p>My feeble attempt was this:</p>
  
  <hr>
  
  <pre><code>SELECT * 
  FROM [TableName] 
  WHERE datecreated &gt; '2016-01-01' 
  AND (
      CASE @tagged 
      WHEN 0 THEN (tagged = 0) 
      WHEN 1 THEN (tagged = 1)
      ELSE (tagged IN(0,1)
      END
  )
  </code></pre>