title: SQL Case for WHERE clause IN
body: <p>I am trying to pass a report parameter to a stored procedure (@Time) to dictate which Category values are returned in my data set via the WHERE clause and don't know the syntax to accomplish this correctly.  I suspect a case/if will need to be used and I've done this before but not when needing to do a WHERE clause IN.</p>
  
  <pre><code>DECLARE @Time AS NVARCHAR
  SET @Time = 'REG' --possible values of 'REG' and 'OT'
  
  SELECT
  f.[Category]    AS [Category]
  
  FROM foo f
  
  WHERE
  @Time =  
    CASE @Time
      WHEN 'REG' THEN f.[Category] IN (A, B, C, D)
      WHEN 'OT' THEN f.[Category] IN (E, F, G) 
  END
  </code></pre>