title: Delete all but some rows - Oracle
body: <p>I want to delete set of the rows from a table. I can decide which rows need to be deleted. I will delete the rows from table only if the count of rows is more than 5 (based on condition). </p>
  
  <p>Consider this sample data</p>
  
  <pre><code>ID--Col1--Col2--
  1   A      X
  2   A      X
  3   A      X
  4   A      X
  5   A      X
  6   A      X
  7   A      X
  8   A      X
  9   A      X
  10   A      X
  11   B      X
  12   B      X
  13   B      X
  14   B      X
  15   C      X
  16   C      X
  17   C      X
  18   D      X
  19   D      X
  </code></pre>
  
  <p>I want to delete 5 Rows of {*, A, X}, I need to keep 5 of them (no matter which one). I wont delete B, C &amp; D since count of them is less then 5.</p>
  
  <p>Like</p>
  
  <pre><code>delete from tableA
   --- I can decide on the rows to delete based on two conditions.
   where col1 = someCondition
     and col2 = someOtherCondition
     and rownum &gt; 5 --- This dint work. I checked.
  </code></pre>
  
  <p>I think perhaps I need to programmaticaly. Any suggestions are greatly appreciated. </p>