title: Delete limited n rows from oracle sql table
body: <p>I want to delete exactly 2 rows/records for each employee that is working in more than 3 projects. Let's say I have this table:</p>
  
  <pre><code>+----------+-------------+
  | employee |  Project    |
  +----------+-------------+
  |   1      |   p1        |
  |   1      |   p2        |
  |   1      |   p3        |
  |   1      |   p4        |
  |   2      |   p1        |
  |   2      |   p3        |
  |   3      |   p1        |
  |   3      |   p4        |
  |   3      |   p5        |
  +----------+-------------+
  </code></pre>
  
  <p>I can query which employees are working in more than 3 projects. In this case the employee with id 1 and the employee with id 3. The query should be:</p>
  
  <pre><code>select employee
    from (
      select employee, count(*) my_count
        from my_table
        group by employee
    ) VW
    where VW.my_count &gt;= 3;
  </code></pre>
  
  <p>It is not important which rows to delete, what is relevant is to delete two rows/records  for every employee that works in more than three projects.
  The resulting table could be for example:</p>
  
  <pre><code>+----------+-------------+
  | employee |  Project    |
  +----------+-------------+
  |   1      |   p1        |
  |   1      |   p2        |
  |   2      |   p1        |
  |   2      |   p3        |
  |   3      |   p1        |
  +----------+-------------+
  </code></pre>