title: Join or group table to remove repetitions in one column only
body: <p>I'm trying to sort out this puzzle for more than few hours now, the table is as below:</p>
  
  <pre><code>table:
  n1  n2  r
  ---------
  A   D   G
  B   D   G
  C   D   G
  A   E   G
  B   E   G
  C   E   G
  A   F   G
  B   F   G
  C   F   G
  </code></pre>
  
  <p>And results expected:</p>
  
  <pre><code>result:
  n1  n2  r
  ---------
  A   D   G   
  B   E   G
  C   F   G
  </code></pre>
  
  <p>I was trying grouping, joining, but no lack. Here is the code, but it gives me completely different results:</p>
  
  <pre><code>select * from table t1
      join table t2
      on t2.r = t1.r
      and t1.n1 &gt; t2.n1
  </code></pre>
  
  <p>In general n1 and n2 should be grouped by r and repetitions in n2 should be removed.</p>