title: SQL query to get lowest 2 values of a counted query selection (using db2)?
body: <p>Imagine I already have a query that returns the following:</p>
  
  <pre><code>Col1 | Col2
  ------------
   A   |   2
   B   |   3
   C   |   3
   D   |   4
   E   |   8
      ...
  </code></pre>
  
  <p>Say I used something like this:</p>
  
  <pre><code>select Col1, count ( * ) as Col2 \ 
  from ...
  where ...
  order by Col2 \ 
  group by Col1 \ 
  </code></pre>
  
  <p>So now, all I want to select are <code>(Col1, Col2)</code> such that it returns the selections <code>(a, b) and (c, d) where (b &gt;= all (Col2)) and (d &gt;= ((all (Col2)) - a)).</code> So for the above example, it would return <code>{(A, 2), (B, 3), (C, 3)}</code>. How do I go about doing this? </p>
  
  <p>Any help would be highly appreciated. Thanks.</p>