title: Using rownum in oracle SQL statement in combination with order by clause
body: <p><strong>Which of the following two SQL statements will return the desired result set</strong> (i.e. the ten rows with Status=0 and the highest StartTimes)?</p>
  
  <p><strong>Will both statements always return the same result set</strong> (StartTime is unique)?</p>
  
  <pre><code>SELECT * 
  FROM MyTable 
  WHERE Status=0 
  AND ROWNUM &lt;= 10 
  ORDER BY StartTime DESC
  
  SELECT * 
  FROM (
      SELECT * 
      FROM MyTable 
      WHERE Status=0 
      ORDER BY StartTime DESC
  ) 
  WHERE ROWNUM &lt;= 10
  </code></pre>
  
  <p><strong>Background</strong>   </p>
  
  <p>My DBAdmin told me that the first statement will <em>first</em> limit the table to 10 rows and than order those random rows by StartTime, which is definitly not what I want.
  From what I learned in <a href="https://stackoverflow.com/a/10429914/220636">that answer</a>, the order by clause of the second statement is redundant and could be removed by an optimizer, which is also not what I want.</p>
  
  <hr>
  
  <p>I asked a <a href="https://stackoverflow.com/q/10429738/220636">similar question</a> concering the <code>limit</code> clause in a query to a SQLite database and am interested in understanding any differences to the above statements (using <code>limit</code> Vs <code>rownum</code>) used with an oracle db.</p>