title: Multiple DISTINCT ON clauses in PostgreSQL
body: <p>Is it possible to select rows that are <code>DISTINCT ON</code> some separate, independent sets of columns?</p>
  <p>Suppose I want all the rows which match the following conditions:</p>
  <ul>
  <li>distinct on <code>(name, birth)</code></li>
  <li>distinct on <code>(name, height)</code></li>
  </ul>
  <p>So that, out of the following table, the rows marked with a red cross would not be distinct (with an indication of the failing clause):</p>
  <pre><code>name      birth    height
  --------------------------
  William    1976      1.82
  James      1981      1.68
  Mike       1976      1.68
  Tom        1967      1.79
  William    1976      1.74   ❌ (name, birth)
  William    1981      1.82   ❌ (name, height)
  Tom        1978      1.92
  Mike       1963      1.68   ❌ (name, height)
  Tom        1971      1.86
  James      1981      1.77   ❌ (name, birth)
  Tom        1971      1.89   ❌ (name, birth)
  </code></pre>
  <p>In the above example, if the <code>DISTINCT ON</code> clause had just been <code>DISTINCT ON (name, birth, height)</code>, then all the rows would have been considered distinct.</p>
  <p>Tried and didn't work:</p>
  <ul>
  <li><code>SELECT DISTINCT ON (name, birth) (name, height) ...</code></li>
  <li><code>SELECT DISTINCT ON (name, birth), (name, height) ...</code></li>
  <li><code>SELECT DISTINCT ON ((name, birth), (name, height)) ...</code></li>
  <li><code>SELECT DISTINCT ON (name, birth) AND (name, height) ...</code></li>
  <li><code>SELECT DISTINCT ON (name, birth) AND ON (name, height) ...</code></li>
  <li><code>SELECT DISTINCT ON (name, birth) DISTINCT ON (name, height) ...</code></li>
  <li><code>SELECT DISTINCT ON (name, birth), DISTINCT ON (name, height) ...</code></li>
  </ul>