title: Conditional SQL Statement
body: <p>I would like to ask if it is possible to create a SQL statement with an if or similar structure. 
  I have two queries and would like to combine them into one. The only difference between the two is that one has additional AND conditions on its WHERE clause. 
  I tried doing a select case, but was not very successful. I will create a parameter "test" that will take 1 or 2, and that condition should determine which query to run.
  Here are the queries... </p>
  
  <p>Query 1</p>
  
  <pre><code>SELECT ID,AVG(B.VOL) AS PVOL
  FROM (SELECT VAR1 AS ID, SUM(VOL) AS PVOL FROM table1 WHERE VAR1='xyz' 
  AND DATE_D&gt;'10/28/2013' AND DATE_D&lt;'10/31/2013'
  AND CUSTOMER='Market' AND MARKET='South' AND PROJECT=0
  GROUP BY VAR1,DATE_D) B GROUP BY ID
  </code></pre>
  
  <p>Query 2</p>
  
  <pre><code>SELECT ID,AVG(B.VOL) AS PVOL
  FROM (SELECT VAR1 AS ID, SUM(VOL) AS PVOL FROM table1 WHERE VAR1='xyz' 
  AND DATE_D&gt;'10/28/2013' AND DATE_D&lt;'10/31/2013'
  AND PROJECT=0
  GROUP BY VAR1,DATE_D) B GROUP BY ID
  </code></pre>