title: Merge rows based on one column SQL
body: <p>I currently have a <code>user_addresses</code> table:</p>
  
  <pre><code>id | name | address_type | address
  ---+------+--------------+----------
   1 | John | HOME         | home addr
   1 | John | MAIL         | mail addr
   2 | Bill | HOME         | home addr
   3 | Rick | HOME         | home addr
   3 | Rick | MAIL         | mail addr
  </code></pre>
  
  <p>I want to build a new view that uses the data from the <code>user_addresses</code> table. When <code>address_type=MAIL</code>, it should use their mail address in the <code>address</code> field. Otherwise it uses their <code>home</code> address:</p>
  
  <pre><code>id | name | address_type | address   | data from other tables
  ---+------+--------------+-----------+-----------------------
   1 | John | MAIL         | mail addr |
   2 | Bill | HOME         | home addr |
   3 | Rick | MAIL         | mail addr |
  </code></pre>
  
  <p>I'm currently flattening the <code>user_addresses</code> table so users are one row and they have home/mail addresses in their own columns. Then I'm selecting from this new flattened view and doing a case statement:</p>
  
  <p><code>case when mail_address is not null then mail_address else home_address end</code></p>
  
  <p>Should I be using <code>max(case when)</code>, a union/minus, or something else?? What is the best way to go about accomplishing this?</p>