 <p>Given your data (where the values are the same in the two columns if they are both there), then:</p> <pre><code>select distinct coalesce(a, b) from table t; </code></pre> <p>If that condition doesn't hold, then you need a <code>union</code>, which Giorgi's answer explains.</p>