title: ROW_NUMBER() OVER() returns the wrong order when used in a nested SQL DB2 query
body: <p>I want the below query to delete the same rows which are returned by this select query:</p>
  
  <pre><code> select emp_id, row_number(), over() as row_num from employee order by date_z desc
  </code></pre>
  
  <p>Delete query: </p>
  
  <pre><code> delete from ( select emp_id, row_number(), over() as row_num from employee order by date_z desc ) where row_num &lt; 100 
  </code></pre>
  
  <p>But the row_num order completely gets reversed when the query is nested.
  So, I end up deleting the last 100 rows instead of the first 100 rows.</p>
  
  <p>A possible solution which works for me is: </p>
  
  <pre><code> delete from ( select emp_id, row_number(), over(order by date_z desc) as row_num from employee order by date_z desc ) where row_num &lt; 100 
  </code></pre>
  
  <p>But most of the web links I went through propose that placing an order by clause in over is not going to ensure correct order. What is the right approach to achieve this?</p>