title: Conditional where clause based on another parameter
body: <p>I have 3 tables : </p>
  
  <pre><code>Stores (
      store_Id
  )
  
  Products(
      product_Id,
      store_Id
  )
  
  Price(
      product_Id,
      currency,
      price   
  )
  </code></pre>
  
  <p>My problem statement is like this: </p>
  
  <p>Produce a result set such that:</p>
  
  <p>if store_Id is 1, then select those Products which have prices less
   than 3</p>
  
  <p>if store_Id is 2, then select those Products which have prices less
   than 5</p>
  
  <p>if store_Id is 3, then select those Products which have prices less
   than 6.5</p>
  
  <p>Result set should contain columns: store_Id, product_Id, currency, price.</p>
  
  <p>I am able to do this in Java by running a query like this in loop and substituting the parameters and finally collecting all the result:</p>
  
  <pre><code>select ... 
  from stores s join products p on s.store_Id = p.store_Id
  join price pr on pr.product_Id = p.product_Id
  where s.store_Id = ?
  and pr.price &lt;= ?
  </code></pre>
  
  <p><strong>My question is</strong>: can this be achieved in SQL itself in just 1 query without using java (reason is: Products and Prices is a mammoth table containing many thousands of records)</p>
  
  <p>I'm on DB2 v10.5</p>