title: How to conditionally remove condition in where clause?
body: <pre><code>SELECT * FROM someTable WHERE someField = 'A' 
  and (EndTime &gt; @someTime OR EndTime IS NULL)
  </code></pre>
  
  <p>Above was the original query. Now I have a new condition to see if to take away <code>EndTime IS NULL</code>.</p>
  
  <pre><code>SET @Throw = 1;
  
  IF @Throw = 1
  BEGIN
      SELECT * FROM someTable WHERE someField = 'A' 
      and (EndTime &gt; @someTime)
  END
  ELSE IF @Throw = 0
  BEGIN
      SELECT * FROM someTable WHERE someField = 'A' 
      and (EndTime &gt; @someTime OR EndTime IS NULL)
  END
  </code></pre>
  
  <p>I'm wondering if this can be achieve in 1 query itself or it has to be in 2 query?</p>