title: PostgreSQL Record Reordering using Update with a Sub-Select
body: <p>I found this solution on the SQL Server forum on how to reorder records in a table. </p>
  
  <pre><code>UPDATE SomeTable
  SET rankcol = SubQuery.Sort_Order
  FROM
      (
      SELECT IDCol, Row_Number() OVER (ORDER BY ValueCOL) as SORT_ORDER
      FROM SomeTable
      ) SubQuery
  INNER JOIN SomeTable ON
  SubQuery.IDCol = SomeTable.IDCol
  </code></pre>
  
  <p>When I try doing the same on PostgreSQL, I get an error message - </p>
  
  <p>ERROR:  table name "sometable" specified more than once</p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thanks!</p>