title: PostgreSQL - How to get distinct on two columns separately?
body: <p>I've a table like this:</p>
  
  <pre><code>Source table "tab"
  column1   column2
        x         1
        x         2
        y         1
        y         2
        y         3
        z         3
  </code></pre>
  
  <p>How can I build the query to get result with unique values in each of two columns separately. For example I'd like to get a result like one of these sets:</p>
  
  <pre><code>column1   column2
        x         1
        y         2
        z         3
  </code></pre>
  
  <p>or</p>
  
  <pre><code>column1   column2
        x         2
        y         1
        z         3
  </code></pre>
  
  <p>or ...</p>
  
  <p>Thanks. </p>