title: Conditional WHERE clause in SQL Server
body: <p>I am creating a SQL query in which I need a conditional <code>where</code> clause.  </p>
  
  <p>It should be something like this:</p>
  
  <pre><code>SELECT 
      DateAppr,
      TimeAppr,
      TAT,
      LaserLTR,
      Permit,
      LtrPrinter,
      JobName,
      JobNumber,
      JobDesc,
      ActQty,
      (ActQty-LtrPrinted) AS L,
      (ActQty-QtyInserted) AS M,
      ((ActQty-LtrPrinted)-(ActQty-QtyInserted)) AS N
  FROM 
      [test].[dbo].[MM]
  WHERE 
      DateDropped = 0
              --This is where i need the conditional clause 
      AND CASE
              WHEN @JobsOnHold = 1 THEN DateAppr &gt;=  0
              ELSE  DateAppr != 0
          END
  </code></pre>
  
  <p>The above query is not working. Is this not the correct syntax or is there another way to do this that I don't know? </p>
  
  <p>I don't want to use dynamic SQL, so is there any other way or do I have to use a workaround like using <code>if else</code> and using the same query with different <code>where</code> clauses?</p>