title: Oracle SQL - select pairs where an index value has its smallest value, EXCEPT when there has already been a previous pair with a smaller value
body: <p>I am trying to select rows from a table where an index column has its minimum value within a partition, under the condition that this row has not already had a match in a previous partition. The selection should work in a kind of draw without replacing-manner.</p>
  <p>Maybe it is better to clarify with an example. Consider the following table:</p>
  <pre><code>ID1   ID2    index
  foo   qux    1
  foo   quux   2
  foo   corge  3
  bar   qux    4
  bar   quux   5
  bar   corge  6
  baz   quux   7
  baz   corge  8
  </code></pre>
  <p>For every group in ID1, starting at the lowest index values, I want to pick the match from ID2 with the minimum index value for this partition (here: <code>qux</code> with an in index value of <code>1</code>).
  Now, for <code>ID1=bar</code>, the matching ID2 would be <code>quux</code> (with an index value of <code>5</code>), since <code>qux</code> has already been picked (and matched to <code>foo</code>).
  Similarly, <code>baz</code> would match with <code>corge</code>because <code>quux</code> was already matched to <code>bar</code>.</p>
  <p>So the resulting query result should be</p>
  <pre><code>ID1   ID2   index
  foo   qux    1
  bar   quux   5
  baz   corqe  8 
  </code></pre>
  <p>Note that not all values in ID1 have all possible values in ID2 and vice versa, also the subgroup sizes in ID1 and ID2 are not constant.</p>
  <p>Any ideas how I could achieve this?</p>
  <p>Edit: the values of ID1 and ID2 don't have any meaning, they are just completely random identifiers. I modified the example to make this clearer.</p>
  <p>Edit2: the solution from @p3consulting looked very promising, but it doesn't work with the following data</p>
  <pre><code>ID1   ID2    index
  a1    b1     1
  a1    b2     2
  a2    b3     3
  a4    b4     4
  </code></pre>
  <p>where it only delivers <code>index=1</code> and not <code>index=3</code>.</p>