title: SQL Query WITH CASE in WHERE clause
body: <p>I have to return rows for an entity.</p>
  
  <p>An entity can have multiple office addresses and one of these office addresses can be a headquarters.</p>
  
  <p>I have a table where I display all the entities but I can only display one address for an entity.</p>
  
  <p>So I have to select at least one address</p>
  
  <ol>
  <li>Address with a headquarters</li>
  </ol>
  
  <p>or </p>
  
  <ol start="2">
  <li><p>Select Top 1 Address</p>
  
  <pre><code>SELECT *
  FROM Entity
  LEFT JOIN ......
  WHERE
     [INSERT  CODE TO GET ADDRESS]
  </code></pre></li>
  </ol>