title: How to select the nth row in a SQL database table?
body: <p>I'm interested in learning some (ideally) database agnostic ways of selecting the <em>n</em>th row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases: </p>
  
  <ul>
  <li>SQL Server</li>
  <li>MySQL</li>
  <li>PostgreSQL</li>
  <li>SQLite</li>
  <li>Oracle</li>
  </ul>
  
  <p>I am currently doing something like the following in SQL Server 2005, but I'd be interested in seeing other's more agnostic approaches:</p>
  
  <pre><code>WITH Ordered AS (
  SELECT ROW_NUMBER() OVER (ORDER BY OrderID) AS RowNumber, OrderID, OrderDate
  FROM Orders)
  SELECT *
  FROM Ordered
  WHERE RowNumber = 1000000
  </code></pre>
  
  <p>Credit for the above SQL: <a href="https://web.archive.org/web/20101103031717/http://weblogs.asp.net/Firoz/archive/2005/06/12/411949.aspx" rel="noreferrer">Firoz Ansari's Weblog</a></p>
  
  <p><strong>Update:</strong> See <a href="https://stackoverflow.com/questions/16568/how-to-select-the-nth-row-in-a-sql-database-table#42765">Troels Arvin's answer</a> regarding the SQL standard. <em>Troels, have you got any links we can cite?</em></p>