title: Oracle: Updating a table column using ROWNUM in conjunction with ORDER BY clause
body: <p>I want to populate a table column with a running integer number, so I'm thinking of using ROWNUM. However, I need to populate it based on the order of other columns, something like <code>ORDER BY column1, column2</code>. That is, unfortunately, not possible since Oracle does not accept the following statement:</p>
  
  <pre><code>UPDATE table_a SET sequence_column = rownum ORDER BY column1, column2;
  </code></pre>
  
  <p>Nor the following statement (an attempt to use WITH clause):</p>
  
  <pre><code>WITH tmp AS (SELECT * FROM table_a ORDER BY column1, column2)
  UPDATE tmp SET sequence_column = rownum;
  </code></pre>
  
  <p>So how do I do it using an SQL statement and without resorting to cursor iteration method in PL/SQL?</p>