title: Oracle Update First 20 Records Based on an Order By
body: <p>I have this table that I am trying to update a column off. The thing is there are 40 records in which I order by an impact. I then want to take the top 10 of those (based on their impact) and update them</p>
  
  <pre><code>UPDATE mytable
  SET status = 'red'
  WHERE status IN
  (
  
      SELECT status
        FROM (
          SELECT *
          FROM mytable
          WHERE status = 'green'
          ORDER BY impact DESC
          )
  )
  AND ROWNUM &lt;= 10
  </code></pre>
  
  <p>I tried putting the ROWNUM inside the WHERE IN statement but it will just ignore it and update all 40 records. When I do it how I have it above then it picks 10 but it doesn't pick the top 10 it just picks them randomly. I am guessing it's ignoring the ORDER BY impact.</p>
  
  <p>I've tried searching for a similar issue but cant find anything.
  Any help is much appreciated! </p>