title: Can you have if-then-else logic in SQL?
body: <p>I need to do select data from a table based on some kind of priority like so:</p>
  
  <pre><code>select product, price from table1 where project = 1
  
  -- pseudo: if no price found, do this:
  select product, price from table1 where customer = 2
  
  -- pseudo: if still no price found, do this:
  select product, price from table1 where company = 3
  </code></pre>
  
  <p>That is, if I found 3 products with prices based on <code>project = X</code>, I don't want to select on <code>customer = Y</code>. I just want to return the resulting 3 rows and be done.</p>
  
  <p>How are you supposed to do stuff like this in SQL? Use some kind of CASE-statement for the pseudo-if's? Do a union or some other smart thing?</p>
  
  <p>Edit: I'm using MS SQL.</p>
  
  <p>Thanks!</p>